This is an automated email from the ASF dual-hosted git repository.
pradeep pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ranger.git
The following commit(s) were added to refs/heads/master by this push:
new b4c3284 RANGER-2713: Remove audit fields from XXPolicyRef objects
XXPolicyRef objects have fields such as create time, update time, added by user
ID, updated by user ID, but there fields are entirely useless since they are
all copied from the XXPolicy object. In addition, while improving performance
for creation of policies with large numbers of users, we discovered that a lot
of time was being spent in JPA converting these Date objects especially. After
removing these fields we [...]
b4c3284 is described below
commit b4c32849245b40d100a583b0b214a69f9b678a44
Author: andrew_luo <[email protected]>
AuthorDate: Thu Jan 30 09:31:25 2020 -0800
RANGER-2713: Remove audit fields from XXPolicyRef objects XXPolicyRef
objects have fields such as create time, update time, added by user ID, updated
by user ID, but there fields are entirely useless since they are all copied
from the XXPolicy object. In addition, while improving performance for creation
of policies with large numbers of users, we discovered that a lot of time was
being spent in JPA converting these Date objects especially. After removing
these fields we saw a signifi [...]
Signed-off-by: Pradeep <[email protected]>
---
...6-drop-audit-columns-from-policy-ref-tables.sql | 90 ++++++++++
...6-drop-audit-columns-from-policy-ref-tables.sql | 61 +++++++
...6-drop-audit-columns-from-policy-ref-tables.sql | 49 +++++
...6-drop-audit-columns-from-policy-ref-tables.sql | 129 ++++++++++++++
...6-drop-audit-columns-from-policy-ref-tables.sql | 197 +++++++++++++++++++++
.../org/apache/ranger/biz/PolicyRefUpdater.java | 17 +-
.../ranger/entity/XXPolicyRefAccessType.java | 2 +-
.../apache/ranger/entity/XXPolicyRefCondition.java | 2 +-
.../ranger/entity/XXPolicyRefDataMaskType.java | 2 +-
.../org/apache/ranger/entity/XXPolicyRefGroup.java | 2 +-
.../apache/ranger/entity/XXPolicyRefResource.java | 2 +-
.../org/apache/ranger/entity/XXPolicyRefRole.java | 2 +-
.../org/apache/ranger/entity/XXPolicyRefUser.java | 2 +-
.../org/apache/ranger/biz/TestServiceDBStore.java | 11 --
14 files changed, 539 insertions(+), 29 deletions(-)
diff --git
a/security-admin/db/mysql/patches/046-drop-audit-columns-from-policy-ref-tables.sql
b/security-admin/db/mysql/patches/046-drop-audit-columns-from-policy-ref-tables.sql
new file mode 100644
index 0000000..e1db3c6
--- /dev/null
+++
b/security-admin/db/mysql/patches/046-drop-audit-columns-from-policy-ref-tables.sql
@@ -0,0 +1,90 @@
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+
+drop procedure if exists drop_table_column;
+delimiter ;;
+create procedure drop_table_column(IN tableName varchar(64), IN columnName
varchar(64)) begin
+ if exists (select * from information_schema.columns where
table_schema=database() and table_name = tableName and column_name =
columnName) then
+ SET @query = CONCAT('ALTER TABLE `', tableName,'` DROP COLUMN `',
columnName,'`');
+ PREPARE stmt FROM @query;
+ EXECUTE stmt;
+ DEALLOCATE PREPARE stmt;
+ end if;
+end;;
+delimiter ;
+
+drop procedure if exists drop_table_foreign_key;
+delimiter ;;
+create procedure drop_table_foreign_key(IN tableName varchar(64), IN
foreignKeyName varchar(64)) begin
+ if exists (select * from information_schema.table_constraints where
table_schema=database() and table_name = tableName and constraint_name =
foreignKeyName and constraint_type = 'FOREIGN KEY') then
+ SET @query = CONCAT('ALTER TABLE `', tableName,'` DROP FOREIGN KEY `',
foreignKeyName,'`');
+ PREPARE stmt FROM @query;
+ EXECUTE stmt;
+ DEALLOCATE PREPARE stmt;
+ end if;
+end;;
+delimiter ;
+
+call drop_table_column('x_policy_ref_resource', 'create_time');
+call drop_table_column('x_policy_ref_resource', 'update_time');
+call drop_table_foreign_key('x_policy_ref_resource',
'x_policy_ref_res_FK_added_by_id');
+call drop_table_column('x_policy_ref_resource', 'added_by_id');
+call drop_table_foreign_key('x_policy_ref_resource',
'x_policy_ref_res_FK_upd_by_id');
+call drop_table_column('x_policy_ref_resource', 'upd_by_id');
+
+call drop_table_column('x_policy_ref_role', 'create_time');
+call drop_table_column('x_policy_ref_role', 'update_time');
+call drop_table_foreign_key('x_policy_ref_role',
'x_policy_ref_role_FK_added_by_id');
+call drop_table_column('x_policy_ref_role', 'added_by_id');
+call drop_table_foreign_key('x_policy_ref_role',
'x_policy_ref_role_FK_upd_by_id');
+call drop_table_column('x_policy_ref_role', 'upd_by_id');
+
+call drop_table_column('x_policy_ref_group', 'create_time');
+call drop_table_column('x_policy_ref_group', 'update_time');
+call drop_table_foreign_key('x_policy_ref_group',
'x_policy_ref_group_FK_added_by_id');
+call drop_table_column('x_policy_ref_group', 'added_by_id');
+call drop_table_foreign_key('x_policy_ref_group',
'x_policy_ref_group_FK_upd_by_id');
+call drop_table_column('x_policy_ref_group', 'upd_by_id');
+
+call drop_table_column('x_policy_ref_user', 'create_time');
+call drop_table_column('x_policy_ref_user', 'update_time');
+call drop_table_foreign_key('x_policy_ref_user',
'x_policy_ref_user_FK_added_by_id');
+call drop_table_column('x_policy_ref_user', 'added_by_id');
+call drop_table_foreign_key('x_policy_ref_user',
'x_policy_ref_user_FK_upd_by_id');
+call drop_table_column('x_policy_ref_user', 'upd_by_id');
+
+call drop_table_column('x_policy_ref_access_type', 'create_time');
+call drop_table_column('x_policy_ref_access_type', 'update_time');
+call drop_table_foreign_key('x_policy_ref_access_type',
'x_policy_ref_access_FK_added_by_id');
+call drop_table_column('x_policy_ref_access_type', 'added_by_id');
+call drop_table_foreign_key('x_policy_ref_access_type',
'x_policy_ref_access_FK_upd_by_id');
+call drop_table_column('x_policy_ref_access_type', 'upd_by_id');
+
+call drop_table_column('x_policy_ref_condition', 'create_time');
+call drop_table_column('x_policy_ref_condition', 'update_time');
+call drop_table_foreign_key('x_policy_ref_condition',
'x_policy_ref_condition_FK_added_by_id');
+call drop_table_column('x_policy_ref_condition', 'added_by_id');
+call drop_table_foreign_key('x_policy_ref_condition',
'x_policy_ref_condition_FK_upd_by_id');
+call drop_table_column('x_policy_ref_condition', 'upd_by_id');
+
+call drop_table_column('x_policy_ref_datamask_type', 'create_time');
+call drop_table_column('x_policy_ref_datamask_type', 'update_time');
+call drop_table_foreign_key('x_policy_ref_datamask_type',
'x_policy_ref_datamask_FK_added_by_id');
+call drop_table_column('x_policy_ref_datamask_type', 'added_by_id');
+call drop_table_foreign_key('x_policy_ref_datamask_type',
'x_policy_ref_datamask_FK_upd_by_id');
+call drop_table_column('x_policy_ref_datamask_type', 'upd_by_id');
+
+drop procedure if exists drop_table_column;
+drop procedure if exists drop_table_foreign_key;
diff --git
a/security-admin/db/oracle/patches/046-drop-audit-columns-from-policy-ref-tables.sql
b/security-admin/db/oracle/patches/046-drop-audit-columns-from-policy-ref-tables.sql
new file mode 100644
index 0000000..405ed6b
--- /dev/null
+++
b/security-admin/db/oracle/patches/046-drop-audit-columns-from-policy-ref-tables.sql
@@ -0,0 +1,61 @@
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+
+CREATE OR REPLACE PROCEDURE spdroptablecolumn(TableName IN varchar2,
ColumnName IN varchar2)
+IS
+ v_column_exists number := 0;
+BEGIN
+ select count(*) into v_column_exists from user_tab_cols where table_name =
upper(TableName) and column_name = upper(ColumnName);
+ if (v_column_exists > 0) then
+ execute immediate 'ALTER TABLE ' || TableName || ' DROP COLUMN ' ||
ColumnName || ' CASCADE CONSTRAINTS';
+ commit;
+ end if;
+END;
+/
+
+call spdroptablecolumn('x_policy_ref_resource', 'create_time');
+call spdroptablecolumn('x_policy_ref_resource', 'update_time');
+call spdroptablecolumn('x_policy_ref_resource', 'added_by_id');
+call spdroptablecolumn('x_policy_ref_resource', 'upd_by_id');
+
+call spdroptablecolumn('x_policy_ref_role', 'create_time');
+call spdroptablecolumn('x_policy_ref_role', 'update_time');
+call spdroptablecolumn('x_policy_ref_role', 'added_by_id');
+call spdroptablecolumn('x_policy_ref_role', 'upd_by_id');
+
+call spdroptablecolumn('x_policy_ref_group', 'create_time');
+call spdroptablecolumn('x_policy_ref_group', 'update_time');
+call spdroptablecolumn('x_policy_ref_group', 'added_by_id');
+call spdroptablecolumn('x_policy_ref_group', 'upd_by_id');
+
+call spdroptablecolumn('x_policy_ref_user', 'create_time');
+call spdroptablecolumn('x_policy_ref_user', 'update_time');
+call spdroptablecolumn('x_policy_ref_user', 'added_by_id');
+call spdroptablecolumn('x_policy_ref_user', 'upd_by_id');
+
+call spdroptablecolumn('x_policy_ref_access_type', 'create_time');
+call spdroptablecolumn('x_policy_ref_access_type', 'update_time');
+call spdroptablecolumn('x_policy_ref_access_type', 'added_by_id');
+call spdroptablecolumn('x_policy_ref_access_type', 'upd_by_id');
+
+call spdroptablecolumn('x_policy_ref_condition', 'create_time');
+call spdroptablecolumn('x_policy_ref_condition', 'update_time');
+call spdroptablecolumn('x_policy_ref_condition', 'added_by_id');
+call spdroptablecolumn('x_policy_ref_condition', 'upd_by_id');
+
+call spdroptablecolumn('x_policy_ref_datamask_type', 'create_time');
+call spdroptablecolumn('x_policy_ref_datamask_type', 'update_time');
+call spdroptablecolumn('x_policy_ref_datamask_type', 'added_by_id');
+call spdroptablecolumn('x_policy_ref_datamask_type', 'upd_by_id');
diff --git
a/security-admin/db/postgres/patches/046-drop-audit-columns-from-policy-ref-tables.sql
b/security-admin/db/postgres/patches/046-drop-audit-columns-from-policy-ref-tables.sql
new file mode 100644
index 0000000..73ead4e
--- /dev/null
+++
b/security-admin/db/postgres/patches/046-drop-audit-columns-from-policy-ref-tables.sql
@@ -0,0 +1,49 @@
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+
+ALTER TABLE x_policy_ref_resource DROP COLUMN IF EXISTS create_time CASCADE;
+ALTER TABLE x_policy_ref_resource DROP COLUMN IF EXISTS update_time CASCADE;
+ALTER TABLE x_policy_ref_resource DROP COLUMN IF EXISTS added_by_id CASCADE;
+ALTER TABLE x_policy_ref_resource DROP COLUMN IF EXISTS upd_by_id CASCADE;
+
+ALTER TABLE x_policy_ref_role DROP COLUMN IF EXISTS create_time CASCADE;
+ALTER TABLE x_policy_ref_role DROP COLUMN IF EXISTS update_time CASCADE;
+ALTER TABLE x_policy_ref_role DROP COLUMN IF EXISTS added_by_id CASCADE;
+ALTER TABLE x_policy_ref_role DROP COLUMN IF EXISTS upd_by_id CASCADE;
+
+ALTER TABLE x_policy_ref_group DROP COLUMN IF EXISTS create_time CASCADE;
+ALTER TABLE x_policy_ref_group DROP COLUMN IF EXISTS update_time CASCADE;
+ALTER TABLE x_policy_ref_group DROP COLUMN IF EXISTS added_by_id CASCADE;
+ALTER TABLE x_policy_ref_group DROP COLUMN IF EXISTS upd_by_id CASCADE;
+
+ALTER TABLE x_policy_ref_user DROP COLUMN IF EXISTS create_time CASCADE;
+ALTER TABLE x_policy_ref_user DROP COLUMN IF EXISTS update_time CASCADE;
+ALTER TABLE x_policy_ref_user DROP COLUMN IF EXISTS added_by_id CASCADE;
+ALTER TABLE x_policy_ref_user DROP COLUMN IF EXISTS upd_by_id CASCADE;
+
+ALTER TABLE x_policy_ref_access_type DROP COLUMN IF EXISTS create_time CASCADE;
+ALTER TABLE x_policy_ref_access_type DROP COLUMN IF EXISTS update_time CASCADE;
+ALTER TABLE x_policy_ref_access_type DROP COLUMN IF EXISTS added_by_id CASCADE;
+ALTER TABLE x_policy_ref_access_type DROP COLUMN IF EXISTS upd_by_id CASCADE;
+
+ALTER TABLE x_policy_ref_condition DROP COLUMN IF EXISTS create_time CASCADE;
+ALTER TABLE x_policy_ref_condition DROP COLUMN IF EXISTS update_time CASCADE;
+ALTER TABLE x_policy_ref_condition DROP COLUMN IF EXISTS added_by_id CASCADE;
+ALTER TABLE x_policy_ref_condition DROP COLUMN IF EXISTS upd_by_id CASCADE;
+
+ALTER TABLE x_policy_ref_datamask_type DROP COLUMN IF EXISTS create_time
CASCADE;
+ALTER TABLE x_policy_ref_datamask_type DROP COLUMN IF EXISTS update_time
CASCADE;
+ALTER TABLE x_policy_ref_datamask_type DROP COLUMN IF EXISTS added_by_id
CASCADE;
+ALTER TABLE x_policy_ref_datamask_type DROP COLUMN IF EXISTS upd_by_id CASCADE;
diff --git
a/security-admin/db/sqlanywhere/patches/046-drop-audit-columns-from-policy-ref-tables.sql
b/security-admin/db/sqlanywhere/patches/046-drop-audit-columns-from-policy-ref-tables.sql
new file mode 100644
index 0000000..10508f6
--- /dev/null
+++
b/security-admin/db/sqlanywhere/patches/046-drop-audit-columns-from-policy-ref-tables.sql
@@ -0,0 +1,129 @@
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+
+CREATE OR REPLACE PROCEDURE dbo.dropTableColumn (@table_name varchar(100),
@column_name varchar(100))
+AS
+BEGIN
+ DECLARE @stmt VARCHAR(300)
+ IF EXISTS(select * from SYS.SYSCOLUMNS where tname = @table_name and cname
= @column_name)
+ BEGIN
+ SET @stmt = 'ALTER TABLE dbo.' + @table_name + ' DROP ' + @column_name;
+ execute(@stmt)
+ END
+END
+GO
+
+CREATE OR REPLACE PROCEDURE dbo.dropTableConstraint (@table_name varchar(100),
@constraint_name varchar(100))
+AS
+BEGIN
+ DECLARE @stmt VARCHAR(300)
+ IF EXISTS(select * from SYS.SYSCONSTRAINT where constraint_name =
@constraint_name)
+ BEGIN
+ SET @stmt = 'ALTER TABLE dbo.' + @table_name + ' DROP CONSTRAINT ' +
@constraint_name;
+ execute(@stmt)
+ END
+END
+GO
+
+call dbo.dropTableColumn('x_policy_ref_resource', 'create_time')
+GO
+call dbo.dropTableColumn('x_policy_ref_resource', 'update_time')
+GO
+call dbo.dropTableConstraint('x_policy_ref_resource', 'added_by_id')
+GO
+call dbo.dropTableColumn('x_policy_ref_resource',
'x_policy_ref_resource_FK_added_by')
+GO
+call dbo.dropTableConstraint('x_policy_ref_resource', 'added_by_id')
+GO
+call dbo.dropTableColumn('x_policy_ref_resource',
'x_policy_ref_resource_FK_upd_by')
+GO
+
+call dbo.dropTableColumn('x_policy_ref_role', 'create_time')
+GO
+call dbo.dropTableColumn('x_policy_ref_role', 'update_time')
+GO
+call dbo.dropTableConstraint('x_policy_ref_role', 'added_by_id')
+GO
+call dbo.dropTableColumn('x_policy_ref_role', 'x_pol_ref_role_FK_upd_by_id')
+GO
+call dbo.dropTableConstraint('x_policy_ref_role', 'added_by_id')
+GO
+call dbo.dropTableColumn('x_policy_ref_role', 'x_pol_ref_role_FK_upd_by_id')
+GO
+
+call dbo.dropTableColumn('x_policy_ref_group', 'create_time')
+GO
+call dbo.dropTableColumn('x_policy_ref_group', 'update_time')
+GO
+call dbo.dropTableConstraint('x_policy_ref_group', 'added_by_id')
+GO
+call dbo.dropTableColumn('x_policy_ref_group',
'x_policy_ref_group_FK_added_by')
+GO
+call dbo.dropTableConstraint('x_policy_ref_group', 'added_by_id')
+GO
+call dbo.dropTableColumn('x_policy_ref_group', 'x_policy_ref_group_FK_upd_by')
+GO
+
+call dbo.dropTableColumn('x_policy_ref_user', 'create_time')
+GO
+call dbo.dropTableColumn('x_policy_ref_user', 'update_time')
+GO
+call dbo.dropTableConstraint('x_policy_ref_user', 'added_by_id')
+GO
+call dbo.dropTableColumn('x_policy_ref_user', 'x_policy_ref_user_FK_added_by')
+GO
+call dbo.dropTableConstraint('x_policy_ref_user', 'added_by_id')
+GO
+call dbo.dropTableColumn('x_policy_ref_user', 'x_policy_ref_user_FK_upd_by')
+GO
+
+call dbo.dropTableColumn('x_policy_ref_access_type', 'create_time')
+GO
+call dbo.dropTableColumn('x_policy_ref_access_type', 'update_time')
+GO
+call dbo.dropTableConstraint('x_policy_ref_access_type', 'added_by_id')
+GO
+call dbo.dropTableColumn('x_policy_ref_access_type',
'x_policy_ref_access_type_FK_added_by')
+GO
+call dbo.dropTableConstraint('x_policy_ref_access_type', 'added_by_id')
+GO
+call dbo.dropTableColumn('x_policy_ref_access_type',
'x_policy_ref_access_type_FK_upd_by')
+GO
+
+call dbo.dropTableColumn('x_policy_ref_condition', 'create_time')
+GO
+call dbo.dropTableColumn('x_policy_ref_condition', 'update_time')
+GO
+call dbo.dropTableConstraint('x_policy_ref_condition', 'added_by_id')
+GO
+call dbo.dropTableColumn('x_policy_ref_condition',
'x_policy_ref_condition_FK_added_by')
+GO
+call dbo.dropTableConstraint('x_policy_ref_condition', 'added_by_id')
+GO
+call dbo.dropTableColumn('x_policy_ref_condition',
'x_policy_ref_condition_FK_upd_by')
+GO
+
+call dbo.dropTableColumn('x_policy_ref_datamask_type', 'create_time')
+GO
+call dbo.dropTableColumn('x_policy_ref_datamask_type', 'update_time')
+GO
+call dbo.dropTableConstraint('x_policy_ref_datamask_type', 'added_by_id')
+GO
+call dbo.dropTableColumn('x_policy_ref_datamask_type',
'x_policy_ref_datamask_type_FK_added_by')
+GO
+call dbo.dropTableConstraint('x_policy_ref_datamask_type', 'added_by_id')
+GO
+call dbo.dropTableColumn('x_policy_ref_datamask_type',
'x_policy_ref_datamask_type_FK_upd_by')
+GO
diff --git
a/security-admin/db/sqlserver/patches/046-drop-audit-columns-from-policy-ref-tables.sql
b/security-admin/db/sqlserver/patches/046-drop-audit-columns-from-policy-ref-tables.sql
new file mode 100644
index 0000000..1af3ec4
--- /dev/null
+++
b/security-admin/db/sqlserver/patches/046-drop-audit-columns-from-policy-ref-tables.sql
@@ -0,0 +1,197 @@
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+
+SET ANSI_NULLS ON
+GO
+SET QUOTED_IDENTIFIER ON
+GO
+SET ANSI_PADDING ON
+GO
+IF EXISTS (
+ SELECT type_desc, type
+ FROM sys.procedures WITH(NOLOCK)
+ WHERE NAME = 'dropTableColumn'
+ AND type = 'P'
+ )
+BEGIN
+ PRINT 'Proc exist with name dbo.dropTableColumn'
+ DROP PROCEDURE dbo.dropTableColumn
+ PRINT 'Proc dropped dbo.dropTableColumn'
+END
+GO
+CREATE PROCEDURE dbo.dropTableColumn
+ -- Add the parameters for the stored procedure here
+ @tablename nvarchar(100),
+ @columnname nvarchar(100)
+AS
+BEGIN
+ IF EXISTS(select * from INFORMATION_SCHEMA.columns where table_name =
@tablename and column_name = @columnname)
+ BEGIN
+ DECLARE @stmt VARCHAR(300);
+ SET @stmt = 'ALTER TABLE [dbo].[' + @tablename + '] DROP COLUMN [' +
@columnname + ']'
+ EXEC (@stmt);
+ END
+END
+GO
+
+SET ANSI_NULLS ON
+GO
+SET QUOTED_IDENTIFIER ON
+GO
+SET ANSI_PADDING ON
+GO
+IF EXISTS (
+ SELECT type_desc, type
+ FROM sys.procedures WITH(NOLOCK)
+ WHERE NAME = 'dropTableConstraint'
+ AND type = 'P'
+ )
+BEGIN
+ PRINT 'Proc exist with name dbo.dropTableConstraint'
+ DROP PROCEDURE dbo.dropTableConstraint
+ PRINT 'Proc dropped dbo.dropTableConstraint'
+END
+GO
+CREATE PROCEDURE dbo.dropTableConstraint
+ -- Add the parameters for the stored procedure here
+ @tablename nvarchar(100),
+ @constraintname nvarchar(100)
+AS
+BEGIN
+ IF (OBJECT_ID(@constraintname) IS NOT NULL)
+ BEGIN
+ DECLARE @stmt VARCHAR(300);
+ SET @stmt = 'ALTER TABLE [dbo].[' + @tablename + '] DROP CONSTRAINT '
+ @constraintname
+ EXEC (@stmt);
+ END
+END
+GO
+
+EXEC dbo.dropTableColumn 'x_policy_ref_resource', 'create_time'
+GO
+EXEC dbo.dropTableColumn 'x_policy_ref_resource', 'update_time'
+GO
+EXEC dbo.dropTableConstraint 'x_policy_ref_resource', 'added_by_id'
+GO
+EXEC dbo.dropTableColumn 'x_policy_ref_resource',
'x_policy_ref_resource_FK_added_by'
+GO
+EXEC dbo.dropTableConstraint 'x_policy_ref_resource', 'added_by_id'
+GO
+EXEC dbo.dropTableColumn 'x_policy_ref_resource',
'x_policy_ref_resource_FK_upd_by'
+GO
+
+EXEC dbo.dropTableColumn 'x_policy_ref_role', 'create_time'
+GO
+EXEC dbo.dropTableColumn 'x_policy_ref_role', 'update_time'
+GO
+EXEC dbo.dropTableConstraint 'x_policy_ref_role', 'added_by_id'
+GO
+EXEC dbo.dropTableColumn 'x_policy_ref_role',
'x_policy_ref_role_FK_added_by_id'
+GO
+EXEC dbo.dropTableConstraint 'x_policy_ref_role', 'added_by_id'
+GO
+EXEC dbo.dropTableColumn 'x_policy_ref_role', 'x_policy_ref_role_FK_upd_by_id'
+GO
+
+EXEC dbo.dropTableColumn 'x_policy_ref_group', 'create_time'
+GO
+EXEC dbo.dropTableColumn 'x_policy_ref_group', 'update_time'
+GO
+EXEC dbo.dropTableConstraint 'x_policy_ref_group', 'added_by_id'
+GO
+EXEC dbo.dropTableColumn 'x_policy_ref_group', 'x_policy_ref_group_FK_added_by'
+GO
+EXEC dbo.dropTableConstraint 'x_policy_ref_group', 'added_by_id'
+GO
+EXEC dbo.dropTableColumn 'x_policy_ref_group', 'x_policy_ref_group_FK_upd_by'
+GO
+
+EXEC dbo.dropTableColumn 'x_policy_ref_user', 'create_time'
+GO
+EXEC dbo.dropTableColumn 'x_policy_ref_user', 'update_time'
+GO
+EXEC dbo.dropTableConstraint 'x_policy_ref_user', 'added_by_id'
+GO
+EXEC dbo.dropTableColumn 'x_policy_ref_user', 'x_policy_ref_user_FK_added_by'
+GO
+EXEC dbo.dropTableConstraint 'x_policy_ref_user', 'added_by_id'
+GO
+EXEC dbo.dropTableColumn 'x_policy_ref_user', 'x_policy_ref_user_FK_upd_by'
+GO
+
+EXEC dbo.dropTableColumn 'x_policy_ref_access_type', 'create_time'
+GO
+EXEC dbo.dropTableColumn 'x_policy_ref_access_type', 'update_time'
+GO
+EXEC dbo.dropTableConstraint 'x_policy_ref_access_type', 'added_by_id'
+GO
+EXEC dbo.dropTableColumn 'x_policy_ref_access_type',
'x_policy_ref_access_type_FK_added_by'
+GO
+EXEC dbo.dropTableConstraint 'x_policy_ref_access_type', 'added_by_id'
+GO
+EXEC dbo.dropTableColumn 'x_policy_ref_access_type',
'x_policy_ref_access_type_FK_upd_by'
+GO
+
+EXEC dbo.dropTableColumn 'x_policy_ref_condition', 'create_time'
+GO
+EXEC dbo.dropTableColumn 'x_policy_ref_condition', 'update_time'
+GO
+EXEC dbo.dropTableConstraint 'x_policy_ref_condition', 'added_by_id'
+GO
+EXEC dbo.dropTableColumn 'x_policy_ref_condition',
'x_policy_ref_condition_FK_added_by'
+GO
+EXEC dbo.dropTableConstraint 'x_policy_ref_condition', 'added_by_id'
+GO
+EXEC dbo.dropTableColumn 'x_policy_ref_condition',
'x_policy_ref_condition_FK_upd_by'
+GO
+
+EXEC dbo.dropTableColumn 'x_policy_ref_datamask_type', 'create_time'
+GO
+EXEC dbo.dropTableColumn 'x_policy_ref_datamask_type', 'update_time'
+GO
+EXEC dbo.dropTableConstraint 'x_policy_ref_datamask_type', 'added_by_id'
+GO
+EXEC dbo.dropTableColumn 'x_policy_ref_datamask_type',
'x_policy_ref_datamask_type_FK_added_by'
+GO
+EXEC dbo.dropTableConstraint 'x_policy_ref_datamask_type', 'added_by_id'
+GO
+EXEC dbo.dropTableColumn 'x_policy_ref_datamask_type',
'x_policy_ref_datamask_type_FK_upd_by'
+GO
+
+IF EXISTS (
+ SELECT type_desc, type
+ FROM sys.procedures WITH(NOLOCK)
+ WHERE NAME = 'dropTableColumn'
+ AND type = 'P'
+ )
+BEGIN
+ PRINT 'Proc exist with name dbo.dropTableColumn'
+ DROP PROCEDURE dbo.dropTableColumn
+ PRINT 'Proc dropped dbo.dropTableColumn'
+END
+GO
+
+IF EXISTS (
+ SELECT type_desc, type
+ FROM sys.procedures WITH(NOLOCK)
+ WHERE NAME = 'dropTableConstraint'
+ AND type = 'P'
+ )
+BEGIN
+ PRINT 'Proc exist with name dbo.dropTableConstraint'
+ DROP PROCEDURE dbo.dropTableConstraint
+ PRINT 'Proc dropped dbo.dropTableConstraint'
+END
+GO
diff --git
a/security-admin/src/main/java/org/apache/ranger/biz/PolicyRefUpdater.java
b/security-admin/src/main/java/org/apache/ranger/biz/PolicyRefUpdater.java
index 85e6aeb..318f9f5 100644
--- a/security-admin/src/main/java/org/apache/ranger/biz/PolicyRefUpdater.java
+++ b/security-admin/src/main/java/org/apache/ranger/biz/PolicyRefUpdater.java
@@ -52,7 +52,6 @@ import
org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemAccess;
import org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemCondition;
import
org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemDataMaskInfo;
import org.apache.ranger.plugin.model.RangerRole;
-import org.apache.ranger.service.RangerAuditFields;
import org.apache.ranger.service.XUserService;
import org.apache.ranger.view.VXGroup;
import org.apache.ranger.view.VXUser;
@@ -69,12 +68,8 @@ public class PolicyRefUpdater {
RangerDaoManager daoMgr;
@Autowired
- RangerAuditFields<?> rangerAuditFields;
-
- @Autowired
XUserMgr xUserMgr;
-
@Autowired
XUserService xUserService;
@@ -142,7 +137,7 @@ public class PolicyRefUpdater {
throw new Exception(resource + ": is not a
valid resource-type. policy='"+ policy.getName() + "' service='"+
policy.getService() + "'");
}
- XXPolicyRefResource xPolRes =
rangerAuditFields.populateAuditFields(new XXPolicyRefResource(), xPolicy);
+ XXPolicyRefResource xPolRes = new XXPolicyRefResource();
xPolRes.setPolicyId(policy.getId());
xPolRes.setResourceDefId(xResDef.getId());
@@ -167,7 +162,7 @@ public class PolicyRefUpdater {
RangerBizUtil.setBulkMode(false);
roleId = createRoleForPolicy(role);
}
- XXPolicyRefRole xPolRole =
rangerAuditFields.populateAuditFields(new XXPolicyRefRole(), xPolicy);
+ XXPolicyRefRole xPolRole = new XXPolicyRefRole();
xPolRole.setPolicyId(policy.getId());
xPolRole.setRoleId(roleId);
@@ -194,7 +189,7 @@ public class PolicyRefUpdater {
groupId = createGroupForPolicy(group);
}
- XXPolicyRefGroup xPolGroup =
rangerAuditFields.populateAuditFields(new XXPolicyRefGroup(), xPolicy);
+ XXPolicyRefGroup xPolGroup = new XXPolicyRefGroup();
xPolGroup.setPolicyId(policy.getId());
xPolGroup.setGroupId(groupId);
@@ -222,7 +217,7 @@ public class PolicyRefUpdater {
userId = createUserForPolicy(user);
}
- XXPolicyRefUser xPolUser =
rangerAuditFields.populateAuditFields(new XXPolicyRefUser(), xPolicy);
+ XXPolicyRefUser xPolUser = new XXPolicyRefUser();
xPolUser.setPolicyId(policy.getId());
xPolUser.setUserId(userId);
@@ -241,7 +236,7 @@ public class PolicyRefUpdater {
throw new Exception(accessType + ": is not a
valid access-type. policy='" + policy.getName() + "' service='" +
policy.getService() + "'");
}
- XXPolicyRefAccessType xPolAccess =
rangerAuditFields.populateAuditFields(new XXPolicyRefAccessType(), xPolicy);
+ XXPolicyRefAccessType xPolAccess = new
XXPolicyRefAccessType();
xPolAccess.setPolicyId(policy.getId());
xPolAccess.setAccessDefId(xAccTypeDef.getId());
@@ -259,7 +254,7 @@ public class PolicyRefUpdater {
throw new Exception(condition + ": is not a
valid condition-type. policy='"+ xPolicy.getName() + "' service='"+
xPolicy.getService() + "'");
}
- XXPolicyRefCondition xPolCond =
rangerAuditFields.populateAuditFields(new XXPolicyRefCondition(), xPolicy);
+ XXPolicyRefCondition xPolCond = new
XXPolicyRefCondition();
xPolCond.setPolicyId(policy.getId());
xPolCond.setConditionDefId(xPolCondDef.getId());
diff --git
a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefAccessType.java
b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefAccessType.java
index 6af8f99..72efe59 100644
---
a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefAccessType.java
+++
b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefAccessType.java
@@ -26,7 +26,7 @@ import java.util.Objects;
@Cacheable
@XmlRootElement
@Table(name = "x_policy_ref_access_type")
-public class XXPolicyRefAccessType extends XXDBBase implements
+public class XXPolicyRefAccessType implements
java.io.Serializable {
private static final long serialVersionUID = 1L;
/**
diff --git
a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefCondition.java
b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefCondition.java
index 4f4409d..02a4f3c 100644
---
a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefCondition.java
+++
b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefCondition.java
@@ -26,7 +26,7 @@ import java.util.Objects;
@Cacheable
@XmlRootElement
@Table(name = "x_policy_ref_condition")
-public class XXPolicyRefCondition extends XXDBBase implements
+public class XXPolicyRefCondition implements
java.io.Serializable {
private static final long serialVersionUID = 1L;
/**
diff --git
a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefDataMaskType.java
b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefDataMaskType.java
index cb92674..85f2467 100644
---
a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefDataMaskType.java
+++
b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefDataMaskType.java
@@ -26,7 +26,7 @@ import java.util.Objects;
@Cacheable
@XmlRootElement
@Table(name = "x_policy_ref_datamask_type")
-public class XXPolicyRefDataMaskType extends XXDBBase implements
+public class XXPolicyRefDataMaskType implements
java.io.Serializable {
private static final long serialVersionUID = 1L;
/**
diff --git
a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefGroup.java
b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefGroup.java
index 32a1b9f..7933cfb 100644
---
a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefGroup.java
+++
b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefGroup.java
@@ -41,7 +41,7 @@ import javax.xml.bind.annotation.XmlRootElement;
@Cacheable
@XmlRootElement
@Table(name="x_policy_ref_group")
-public class XXPolicyRefGroup extends XXDBBase implements Serializable {
+public class XXPolicyRefGroup implements Serializable {
private static final long serialVersionUID = 1L;
/**
diff --git
a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefResource.java
b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefResource.java
index 1150646..46a8a77 100644
---
a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefResource.java
+++
b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefResource.java
@@ -26,7 +26,7 @@ import java.util.Objects;
@Cacheable
@XmlRootElement
@Table(name = "x_policy_ref_resource")
-public class XXPolicyRefResource extends XXDBBase implements
+public class XXPolicyRefResource implements
java.io.Serializable {
private static final long serialVersionUID = 1L;
/**
diff --git
a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefRole.java
b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefRole.java
index 7aee502..4487c61 100644
--- a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefRole.java
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefRole.java
@@ -41,7 +41,7 @@ import javax.xml.bind.annotation.XmlRootElement;
@Cacheable
@XmlRootElement
@Table(name="x_policy_ref_role")
-public class XXPolicyRefRole extends XXDBBase implements Serializable {
+public class XXPolicyRefRole implements Serializable {
private static final long serialVersionUID = 1L;
/**
diff --git
a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefUser.java
b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefUser.java
index 8dfb928..54ecd05 100644
--- a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefUser.java
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefUser.java
@@ -26,7 +26,7 @@ import java.util.Objects;
@Cacheable
@XmlRootElement
@Table(name = "x_policy_ref_user")
-public class XXPolicyRefUser extends XXDBBase implements
+public class XXPolicyRefUser implements
java.io.Serializable {
private static final long serialVersionUID = 1L;
/**
diff --git
a/security-admin/src/test/java/org/apache/ranger/biz/TestServiceDBStore.java
b/security-admin/src/test/java/org/apache/ranger/biz/TestServiceDBStore.java
index 69c8a4c..7abd888 100644
--- a/security-admin/src/test/java/org/apache/ranger/biz/TestServiceDBStore.java
+++ b/security-admin/src/test/java/org/apache/ranger/biz/TestServiceDBStore.java
@@ -832,32 +832,21 @@ public class TestServiceDBStore {
policyRefAccessType.setId(Id);
policyRefAccessType.setAccessTypeName("myAccessType");
policyRefAccessType.setPolicyId(Id);
- policyRefAccessType.setCreateTime(new Date());
- policyRefAccessType.setUpdateTime(new Date());
- policyRefAccessType.setAddedByUserId(Id);
- policyRefAccessType.setUpdatedByUserId(Id);
policyRefAccessTypeList.add(policyRefAccessType);
List<XXPolicyRefCondition> policyRefConditionsList = new
ArrayList<XXPolicyRefCondition>();
XXPolicyRefCondition policyRefCondition = new
XXPolicyRefCondition();
policyRefCondition.setId(Id);
- policyRefCondition.setAddedByUserId(Id);
policyRefCondition.setConditionDefId(Id);
policyRefCondition.setConditionName("myConditionName");
policyRefCondition.setPolicyId(Id);
- policyRefCondition.setUpdatedByUserId(Id);
- policyRefCondition.setCreateTime(new Date());
- policyRefCondition.setUpdateTime(new Date());
policyRefConditionsList.add(policyRefCondition);
List<XXPolicyRefResource> policyRefResourcesList = new
ArrayList<XXPolicyRefResource>();
XXPolicyRefResource policyRefResource = new
XXPolicyRefResource();
- policyRefResource.setAddedByUserId(Id);
- policyRefResource.setCreateTime(new Date());
policyRefResource.setId(Id);
policyRefResource.setPolicyId(Id);
policyRefResource.setResourceDefId(Id);
- policyRefResource.setUpdateTime(new Date());
policyRefResource.setResourceName("myresourceName");
policyRefResourcesList.add(policyRefResource);