Repository: incubator-ranger
Updated Branches:
  refs/heads/tag-policy 001ec8837 -> f08d5b361


RANGER-274: updated DB schema for tag-based-policy for the following:
 - rename table x_service_resource_element_value to 
x_service_resource_element_val, to comply with table name length restrictions
 - remove unused guid columns
 - add missed UNIQUE KEY constraint to guid columns
 - resized columns with UNIQUE constraint to be 256 or less

Signed-off-by: Madhan Neethiraj <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/f08d5b36
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/f08d5b36
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/f08d5b36

Branch: refs/heads/tag-policy
Commit: f08d5b361f633952bf00a8660cab0e0f4e00c7f5
Parents: 001ec88
Author: Gautam Borad <[email protected]>
Authored: Tue Sep 22 09:35:03 2015 +0530
Committer: Madhan Neethiraj <[email protected]>
Committed: Wed Sep 23 13:26:57 2015 -0700

----------------------------------------------------------------------
 .../016-updated-schema-for-tag-based-policy.sql | 421 +++++++------------
 .../java/org/apache/ranger/biz/TagDBStore.java  |   4 -
 .../java/org/apache/ranger/common/GUIDUtil.java |  13 +-
 .../ranger/entity/XXServiceResourceElement.java |  25 --
 .../entity/XXServiceResourceElementValue.java   |  27 +-
 .../apache/ranger/entity/XXTagAttribute.java    |  29 +-
 .../apache/ranger/entity/XXTagAttributeDef.java |  25 --
 .../ranger/service/RangerTagDefServiceBase.java |   1 -
 8 files changed, 153 insertions(+), 392 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f08d5b36/security-admin/db/mysql/patches/016-updated-schema-for-tag-based-policy.sql
----------------------------------------------------------------------
diff --git 
a/security-admin/db/mysql/patches/016-updated-schema-for-tag-based-policy.sql 
b/security-admin/db/mysql/patches/016-updated-schema-for-tag-based-policy.sql
index 10eaf4c..89c5cbe 100644
--- 
a/security-admin/db/mysql/patches/016-updated-schema-for-tag-based-policy.sql
+++ 
b/security-admin/db/mysql/patches/016-updated-schema-for-tag-based-policy.sql
@@ -13,311 +13,182 @@
 -- See the License for the specific language governing permissions and
 -- limitations under the License.
 
--- Temporary table structure for view `vx_trx_log`
---
-
--- -----------------------------------------------------
--- Table `x_tag_def`
--- -----------------------------------------------------
+DROP TABLE IF EXISTS `x_service_resource_element_val` ;
 DROP TABLE IF EXISTS `x_tag_resource_map` ;
-DROP TABLE IF EXISTS `x_service_resource_element_value` ;
+DROP TABLE IF EXISTS `x_tag_attr` ;
+DROP TABLE IF EXISTS `x_tag_attr_def` ;
 DROP TABLE IF EXISTS `x_service_resource_element` ;
 DROP TABLE IF EXISTS `x_service_resource` ;
-DROP TABLE IF EXISTS `x_tag_attr` ;
 DROP TABLE IF EXISTS `x_tag` ;
-DROP TABLE IF EXISTS `x_tag_attr_def` ;
 DROP TABLE IF EXISTS `x_tag_def` ;
-
+-- -----------------------------------------------------
+-- Table `x_tag_def`
+-- -----------------------------------------------------
 CREATE TABLE IF NOT EXISTS `x_tag_def` (
-  `id` BIGINT(20) NOT NULL AUTO_INCREMENT,
-  `guid` VARCHAR(512) NOT NULL,
-  `create_time` DATETIME NULL,
-  `update_time` DATETIME NULL,
-  `added_by_id` BIGINT(20) NULL,
-  `upd_by_id` BIGINT(20) NULL,
-  `version` BIGINT(20) NULL,
-  `name` VARCHAR(512) NOT NULL,
-  `source` VARCHAR(128) NULL,
-  `is_enabled` TINYINT NULL DEFAULT 1,
-  PRIMARY KEY (`id`),
-  UNIQUE INDEX `guid_UNIQUE` (`guid` ASC),
-  UNIQUE INDEX `name_UNIQUE` (`name` ASC),
-  INDEX `fk_X_TAG_DEF_NAME` (`name` ASC),
-  INDEX `fk_X_TAG_DEF_ADDED_BY_ID` (`added_by_id` ASC),
-  INDEX `fk_X_TAG_DEF_UPD_BY_ID` (`upd_by_id` ASC),
-  CONSTRAINT `fk_X_TAG_DEF_ADDED_BY_ID`
-    FOREIGN KEY (`added_by_id`)
-    REFERENCES `x_portal_user` (`id`)
-    ON DELETE RESTRICT
-    ON UPDATE RESTRICT,
-  CONSTRAINT `fk_X_TAG_DEF_UPD_BY_ID`
-    FOREIGN KEY (`upd_by_id`)
-    REFERENCES `x_portal_user` (`id`)
-    ON DELETE RESTRICT
-    ON UPDATE RESTRICT)
-;
-
-
+`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
+`guid` VARCHAR(64) NOT NULL,
+`create_time` DATETIME DEFAULT NULL,
+`update_time` DATETIME DEFAULT NULL,
+`added_by_id` BIGINT(20) DEFAULT NULL,
+`upd_by_id` BIGINT(20) DEFAULT NULL,
+`version` BIGINT(20) DEFAULT NULL,
+`name` VARCHAR(255) NOT NULL,
+`source` VARCHAR(128) DEFAULT NULL,
+`is_enabled` TINYINT(1) NOT NULL DEFAULT '0',
+PRIMARY KEY (`id`),
+UNIQUE KEY `x_tag_def_UK_guid` (`guid`),
+UNIQUE KEY `x_tag_def_UK_name` (`name`),
+KEY `x_tag_def_IDX_added_by_id` (`added_by_id`),
+KEY `x_tag_def_IDX_upd_by_id` (`upd_by_id`),
+CONSTRAINT `x_tag_def_FK_added_by_id` FOREIGN KEY (`added_by_id`) REFERENCES 
`x_portal_user` (`id`),
+CONSTRAINT `x_tag_def_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES 
`x_portal_user` (`id`)
+);
 -- -----------------------------------------------------
 -- Table `x_tag`
 -- -----------------------------------------------------
-
 CREATE TABLE IF NOT EXISTS `x_tag` (
-  `id` BIGINT(20) NOT NULL AUTO_INCREMENT,
-  `guid` VARCHAR(512) NOT NULL,
-  `create_time` DATETIME NULL,
-  `update_time` DATETIME NULL,
-  `added_by_id` BIGINT(20) NULL,
-  `upd_by_id` BIGINT(20) NULL,
-  `type` BIGINT(20) NOT NULL,
-  PRIMARY KEY (`id`),
-  INDEX `fk_X_TAG_TYPE` (`type` ASC),
-  INDEX `fk_X_TAG_ADDED_BY_ID` (`added_by_id` ASC),
-  INDEX `fk_X_TAG_UPD_BY_ID` (`upd_by_id` ASC),
-  CONSTRAINT `fk_X_TAG_TYPE`
-    FOREIGN KEY (`type`)
-    REFERENCES `x_tag_def` (`id`)
-    ON DELETE NO ACTION
-    ON UPDATE NO ACTION,
-  CONSTRAINT `fk_X_TAG_ADDED_BY_ID`
-    FOREIGN KEY (`added_by_id`)
-    REFERENCES `x_portal_user` (`id`)
-    ON DELETE RESTRICT
-    ON UPDATE RESTRICT,
-  CONSTRAINT `fk_X_TAG_UPD_BY_ID`
-    FOREIGN KEY (`upd_by_id`)
-    REFERENCES `x_portal_user` (`id`)
-    ON DELETE RESTRICT
-    ON UPDATE RESTRICT)
-;
-
-
-
+`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
+`guid` VARCHAR(64) NOT NULL,
+`create_time` DATETIME DEFAULT NULL,
+`update_time` DATETIME DEFAULT NULL,
+`added_by_id` BIGINT(20) DEFAULT NULL,
+`upd_by_id` BIGINT(20) DEFAULT NULL,
+`type` BIGINT(20) NOT NULL,
+PRIMARY KEY (`id`),
+UNIQUE KEY `x_tag_UK_guid` (`guid`),
+KEY `x_tag_IDX_type` (`type`),
+KEY `x_tag_IDX_added_by_id` (`added_by_id`),
+KEY `x_tag_IDX_upd_by_id` (`upd_by_id`),
+CONSTRAINT `x_tag_FK_type` FOREIGN KEY (`type`) REFERENCES `x_tag_def` (`id`),
+CONSTRAINT `x_tag_FK_added_by_id` FOREIGN KEY (`added_by_id`) REFERENCES 
`x_portal_user` (`id`),
+CONSTRAINT `x_tag_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES 
`x_portal_user` (`id`)
+);
 -- -----------------------------------------------------
 -- Table `x_service_resource`
 -- -----------------------------------------------------
-
 CREATE TABLE IF NOT EXISTS `x_service_resource` (
-  `id` BIGINT(20) NOT NULL AUTO_INCREMENT,
-  `guid` VARCHAR(512) NOT NULL,
-  `create_time` DATETIME NULL,
-  `update_time` DATETIME NULL,
-  `added_by_id` BIGINT(20) NULL,
-  `upd_by_id` BIGINT(20) NULL,
-  `version` BIGINT(20) NULL,
-  `service_id` BIGINT(20) NOT NULL,
-  `resource_signature` varchar(128) DEFAULT NULL,
-  `is_enabled` TINYINT NULL DEFAULT 1,
-  PRIMARY KEY (`id`),
-  INDEX `fk_X_SERVICE_RESOURCE_ADDED_BY_ID` (`added_by_id` ASC),
-  INDEX `fk_X_SERVICE_RESOURCE_UPD_BY_ID` (`upd_by_id` ASC),
-  CONSTRAINT `fk_X_SERVICE_RESOURCE_SERVICE_ID`
-    FOREIGN KEY (`service_id`)
-    REFERENCES `x_service` (`id`)
-    ON DELETE RESTRICT
-    ON UPDATE RESTRICT,
-  CONSTRAINT `fk_X_SERVICE_RESOURCE_ADDED_BY_ID`
-    FOREIGN KEY (`added_by_id`)
-    REFERENCES `x_portal_user` (`id`)
-    ON DELETE RESTRICT
-    ON UPDATE RESTRICT,
-  CONSTRAINT `fk_X_SERVICE_RESOURCE_UPD_BY_ID`
-    FOREIGN KEY (`upd_by_id`)
-    REFERENCES `x_portal_user` (`id`)
-    ON DELETE RESTRICT
-    ON UPDATE RESTRICT)
-;
-
-
+`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
+`guid` VARCHAR(64) NOT NULL,
+`create_time` DATETIME DEFAULT NULL,
+`update_time` DATETIME DEFAULT NULL,
+`added_by_id` BIGINT(20) DEFAULT NULL,
+`upd_by_id` BIGINT(20) DEFAULT NULL,
+`version` BIGINT(20) DEFAULT NULL,
+`service_id` BIGINT(20) NOT NULL,
+`resource_signature` varchar(128) DEFAULT NULL,
+`is_enabled` TINYINT NOT NULL DEFAULT '1',
+PRIMARY KEY (`id`),
+UNIQUE KEY `x_service_resource_UK_guid` (`guid`),
+KEY `x_service_res_IDX_added_by_id` (`added_by_id`),
+KEY `x_service_res_IDX_upd_by_id` (`upd_by_id`),
+CONSTRAINT `x_service_res_FK_service_id` FOREIGN KEY (`service_id`) REFERENCES 
`x_service` (`id`),
+CONSTRAINT `x_service_res_FK_added_by_id` FOREIGN KEY (`added_by_id`) 
REFERENCES `x_portal_user` (`id`),
+CONSTRAINT `x_service_res_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES 
`x_portal_user` (`id`)
+);
 -- -----------------------------------------------------
 -- Table `x_service_resource_element`
 -- -----------------------------------------------------
-
 CREATE TABLE IF NOT EXISTS `x_service_resource_element` (
-  `id` BIGINT(20) NOT NULL AUTO_INCREMENT,
-  `guid` VARCHAR(512) NOT NULL,
-  `create_time` DATETIME NULL,
-  `update_time` DATETIME NULL,
-  `added_by_id` BIGINT(20) NULL,
-  `upd_by_id` BIGINT(20) NULL,
-  `res_id` BIGINT(20) NOT NULL,
-  `res_def_id` BIGINT(20) NOT NULL,
-  `is_excludes` TINYINT(1) NULL DEFAULT false,
-  `is_recursive` TINYINT(1) NULL DEFAULT false,
-  PRIMARY KEY (`id`),
-  INDEX `fk_X_SERVICE_RESOURCE_ELEMENT_ADDED_BY_ID` (`added_by_id` ASC),
-  INDEX `fk_X_SERVICE_RESOURCE_ELEMENT_UPD_BY_ID` (`upd_by_id` ASC),
-  CONSTRAINT `fk_X_SERVICE_RESOURCE_ELEMENT_res_def_id` 
-    FOREIGN KEY (`res_def_id`) 
-    REFERENCES `x_resource_def` (`id`)
-    ON DELETE RESTRICT
-    ON UPDATE RESTRICT,
-  CONSTRAINT `fk_X_SERVICE_RESOURCE_ELEMENT_res_id` 
-    FOREIGN KEY (`res_id`) 
-    REFERENCES `x_service_resource` (`id`)
-    ON DELETE RESTRICT
-    ON UPDATE RESTRICT,
-  CONSTRAINT `fk_X_SERVICE_RESOURCE_ELEMENT_ADDED_BY_ID`
-    FOREIGN KEY (`added_by_id`)
-    REFERENCES `x_portal_user` (`id`)
-    ON DELETE RESTRICT
-    ON UPDATE RESTRICT,
-  CONSTRAINT `fk_X_SERVICE_RESOURCE_ELEMENT_UPD_BY_ID`
-    FOREIGN KEY (`upd_by_id`)
-    REFERENCES `x_portal_user` (`id`)
-    ON DELETE RESTRICT
-    ON UPDATE RESTRICT)
-;
-
+`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
+`create_time` DATETIME DEFAULT NULL,
+`update_time` DATETIME DEFAULT NULL,
+`added_by_id` BIGINT(20) DEFAULT NULL,
+`upd_by_id` BIGINT(20) DEFAULT NULL,
+`res_id` BIGINT(20) NOT NULL,
+`res_def_id` BIGINT(20) NOT NULL,
+`is_excludes` TINYINT(1) NOT NULL DEFAULT '0',
+`is_recursive` TINYINT(1) NOT NULL DEFAULT '0',
+PRIMARY KEY (`id`),
+KEY `x_srvc_res_el_IDX_added_by_id` (`added_by_id`),
+KEY `x_srvc_res_el_IDX_upd_by_id` (`upd_by_id`),
+CONSTRAINT `x_srvc_res_el_FK_res_def_id` FOREIGN KEY (`res_def_id`) REFERENCES 
`x_resource_def` (`id`),
+CONSTRAINT `x_srvc_res_el_FK_res_id` FOREIGN KEY (`res_id`) REFERENCES 
`x_service_resource` (`id`),
+CONSTRAINT `x_srvc_res_el_FK_added_by_id` FOREIGN KEY (`added_by_id`) 
REFERENCES `x_portal_user` (`id`),
+CONSTRAINT `x_srvc_res_el_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES 
`x_portal_user` (`id`)
+);
 -- -----------------------------------------------------
 -- Table `x_tag_attr_def`
 -- -----------------------------------------------------
-
 CREATE TABLE IF NOT EXISTS `x_tag_attr_def` (
-  `id` BIGINT(20) NOT NULL AUTO_INCREMENT,
-  `guid` VARCHAR(512) NOT NULL,
-  `create_time` DATETIME NULL,
-  `update_time` DATETIME NULL,
-  `added_by_id` BIGINT(20) NULL,
-  `upd_by_id` BIGINT(20) NULL,
-  `tag_def_id` BIGINT(20) NOT NULL,
-  `name` VARCHAR(512) NOT NULL,
-  `type` VARCHAR(45) NOT NULL,
-  PRIMARY KEY (`id`),
-  INDEX `fk_X_TAG_ATTR_DEF_TAG_DEF_ID` (`tag_def_id` ASC),
-  INDEX `fk_X_TAG_ATTR_DEF_ADDED_BY_ID` (`added_by_id` ASC),
-  INDEX `fk_X_TAG_ATTR_DEF_UPD_BY_ID` (`upd_by_id` ASC),
-  CONSTRAINT `fk_X_TAG_ATTR_DEF_TAG_DEF_ID`
-    FOREIGN KEY (`tag_def_id`)
-    REFERENCES `x_tag_def` (`id`)
-    ON DELETE RESTRICT
-    ON UPDATE RESTRICT,
-  CONSTRAINT `fk_X_TAG_ATTR_DEF_ADDED_BY_ID`
-    FOREIGN KEY (`added_by_id`)
-    REFERENCES `x_portal_user` (`id`)
-    ON DELETE RESTRICT
-    ON UPDATE RESTRICT,
-  CONSTRAINT `fk_X_TAG_ATTR_DEF_UPD_BY_ID`
-    FOREIGN KEY (`upd_by_id`)
-    REFERENCES `x_portal_user` (`id`)
-    ON DELETE RESTRICT
-    ON UPDATE RESTRICT)
-;
-
-
+`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
+`create_time` DATETIME DEFAULT NULL,
+`update_time` DATETIME DEFAULT NULL,
+`added_by_id` BIGINT(20) DEFAULT NULL,
+`upd_by_id` BIGINT(20) DEFAULT NULL,
+`tag_def_id` BIGINT(20) NOT NULL,
+`name` VARCHAR(255) NOT NULL,
+`type` VARCHAR(45) NOT NULL,
+PRIMARY KEY (`id`),
+KEY `x_tag_attr_def_IDX_tag_def_id` (`tag_def_id`),
+KEY `x_tag_attr_def_IDX_added_by_id` (`added_by_id`),
+KEY `x_tag_attr_def_IDX_upd_by_id` (`upd_by_id`),
+CONSTRAINT `x_tag_attr_def_FK_tag_def_id` FOREIGN KEY (`tag_def_id`) 
REFERENCES `x_tag_def` (`id`),
+CONSTRAINT `x_tag_attr_def_FK_added_by_id` FOREIGN KEY (`added_by_id`) 
REFERENCES `x_portal_user` (`id`),
+CONSTRAINT `x_tag_attr_def_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES 
`x_portal_user` (`id`)
+);
 -- -----------------------------------------------------
 -- Table `x_tag_attr`
 -- -----------------------------------------------------
-
 CREATE TABLE IF NOT EXISTS `x_tag_attr` (
-  `id` BIGINT(20) NOT NULL AUTO_INCREMENT,
-  `guid` VARCHAR(512) NOT NULL,
-  `create_time` DATETIME NULL,
-  `update_time` DATETIME NULL,
-  `added_by_id` BIGINT(20) NULL,
-  `upd_by_id` BIGINT(20) NULL,
-  `tag_id` BIGINT(20) NOT NULL,
-  `attr_name` VARCHAR(128) NOT NULL,
-  `attr_value` VARCHAR(512) NOT NULL,
-  PRIMARY KEY (`id`),
-  INDEX `fk_X_TAG_ID` (`tag_id` ASC),
-  INDEX `fk_X_TAG_ATTR_ADDED_BY_ID` (`added_by_id` ASC),
-  INDEX `fk_X_TAG_ATTR_UPD_BY_ID` (`upd_by_id` ASC),
-  CONSTRAINT `fk_X_TAG_ATTR_TAG_ID`
-    FOREIGN KEY (`tag_id`)
-    REFERENCES `x_tag` (`id`)
-    ON DELETE RESTRICT
-    ON UPDATE RESTRICT,
-  CONSTRAINT `fk_X_TAG_ATTR_ADDED_BY_ID`
-    FOREIGN KEY (`added_by_id`)
-    REFERENCES `x_portal_user` (`id`)
-    ON DELETE RESTRICT
-    ON UPDATE RESTRICT,
-  CONSTRAINT `fk_X_TAG_ATTR_UPD_BY_ID`
-    FOREIGN KEY (`upd_by_id`)
-    REFERENCES `x_portal_user` (`id`)
-    ON DELETE RESTRICT
-    ON UPDATE RESTRICT)
-;
-
-
+`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
+`create_time` DATETIME DEFAULT NULL,
+`update_time` DATETIME DEFAULT NULL,
+`added_by_id` BIGINT(20) DEFAULT NULL,
+`upd_by_id` BIGINT(20) DEFAULT NULL,
+`tag_id` BIGINT(20) NOT NULL,
+`name` VARCHAR(255) NOT NULL,
+`value` VARCHAR(512) NULL,
+PRIMARY KEY (`id`),
+KEY `x_tag_attr_IDX_tag_id` (`tag_id`),
+KEY `x_tag_attr_IDX_added_by_id` (`added_by_id`),
+KEY `x_tag_attr_IDX_upd_by_id` (`upd_by_id`),
+CONSTRAINT `x_tag_attr_FK_tag_id` FOREIGN KEY (`tag_id`) REFERENCES `x_tag` 
(`id`),
+CONSTRAINT `x_tag_attr_FK_added_by_id` FOREIGN KEY (`added_by_id`) REFERENCES 
`x_portal_user` (`id`),
+CONSTRAINT `x_tag_attr_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES 
`x_portal_user` (`id`)
+);
 -- -----------------------------------------------------
 -- Table `x_tag_resource_map`
 -- -----------------------------------------------------
-
 CREATE TABLE IF NOT EXISTS `x_tag_resource_map` (
-  `id` BIGINT(20) NOT NULL AUTO_INCREMENT,
-  `guid` VARCHAR(512) NOT NULL,
-  `create_time` DATETIME NULL,
-  `update_time` DATETIME NULL,
-  `added_by_id` BIGINT(20) NULL,
-  `upd_by_id` BIGINT(20) NULL,
-  `tag_id` BIGINT(20) NOT NULL,
-  `res_id` BIGINT(20) NOT NULL,
-  PRIMARY KEY (`id`),
-  INDEX `fk_X_TAG_ID` (`tag_id` ASC),
-  INDEX `fk_X_SERVICE_RES_ID` (`res_id` ASC),
-  INDEX `fk_X_TAG_RES_MAP_ADDED_BY_ID` (`added_by_id` ASC),
-  INDEX `fk_X_TAG_RES_MAP_UPD_BY_ID` (`upd_by_id` ASC),
-  CONSTRAINT `fk_X_TAG_RES_MAP_TAG_ID`
-    FOREIGN KEY (`tag_id`)
-    REFERENCES `x_tag` (`id`)
-    ON DELETE RESTRICT
-    ON UPDATE RESTRICT,
-  CONSTRAINT `fk_X_TAG_RES_MAP_SERVICE_RES_ID`
-    FOREIGN KEY (`res_id`)
-    REFERENCES `x_service_resource` (`id`)
-    ON DELETE RESTRICT
-    ON UPDATE RESTRICT,
-  CONSTRAINT `fk_X_TAG_RES_MAP_ADDED_BY_ID`
-    FOREIGN KEY (`added_by_id`)
-    REFERENCES `x_portal_user` (`id`)
-    ON DELETE RESTRICT
-    ON UPDATE RESTRICT,
-  CONSTRAINT `fk_X_TAG_RES_MAP_UPD_BY_ID`
-    FOREIGN KEY (`upd_by_id`)
-    REFERENCES `x_portal_user` (`id`)
-    ON DELETE RESTRICT
-    ON UPDATE RESTRICT)
-;
-
-
--- -----------------------------------------------------
--- Table `x_service_resource_element_value`
--- -----------------------------------------------------
-
-CREATE TABLE IF NOT EXISTS `x_service_resource_element_value` (
-  `id` BIGINT(20) NOT NULL AUTO_INCREMENT,
-  `guid` VARCHAR(512) NOT NULL,
-  `create_time` DATETIME NULL,
-  `update_time` DATETIME NULL,
-  `added_by_id` BIGINT(20) NULL,
-  `upd_by_id` BIGINT(20) NULL,
-  `res_element_id` BIGINT(20) NOT NULL,
-  `value` VARCHAR(512) NOT NULL,
-  `sort_order` INT NULL,
-  PRIMARY KEY (`id`),
-  INDEX `fk_X_RESOURCE_ELEMENT_ID` (`res_element_id` ASC),
-  INDEX `fk_X_SERVICE_RES_VAL_MAP_ADDED_BY_ID` (`added_by_id` ASC),
-  INDEX `fk_X_SERVICE_RES_VAL_MAP_UPD_BY_ID` (`upd_by_id` ASC),
-  CONSTRAINT `fk_X_RESOURCE_ELEMENT_ID`
-    FOREIGN KEY (`res_element_id`)
-    REFERENCES `x_service_resource_element` (`id`)
-    ON DELETE RESTRICT
-    ON UPDATE RESTRICT,
-  CONSTRAINT `fk_X_SERVICE_RES_VAL_MAP_ADDED_BY_ID`
-    FOREIGN KEY (`added_by_id`)
-    REFERENCES `x_portal_user` (`id`)
-    ON DELETE RESTRICT
-    ON UPDATE RESTRICT,
-  CONSTRAINT `fk_X_SERVICE_RES_VAL_MAP_UPD_BY_ID`
-    FOREIGN KEY (`upd_by_id`)
-    REFERENCES `x_portal_user` (`id`)
-    ON DELETE RESTRICT
-    ON UPDATE RESTRICT)
-;
-
-
+`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
+`guid` VARCHAR(64) NOT NULL,
+`create_time` DATETIME DEFAULT NULL,
+`update_time` DATETIME DEFAULT NULL,
+`added_by_id` BIGINT(20) DEFAULT NULL,
+`upd_by_id` BIGINT(20) DEFAULT NULL,
+`tag_id` BIGINT(20) NOT NULL,
+`res_id` BIGINT(20) NOT NULL,
+PRIMARY KEY (`id`),
+UNIQUE KEY `x_tag_resource_map_UK_guid` (`guid`),
+KEY `x_tag_res_map_IDX_tag_id` (`tag_id`),
+KEY `x_tag_res_map_IDX_res_id` (`res_id`),
+KEY `x_tag_res_map_IDX_added_by_id` (`added_by_id`),
+KEY `x_tag_res_map_IDX_upd_by_id` (`upd_by_id`),
+CONSTRAINT `x_tag_res_map_FK_tag_id` FOREIGN KEY (`tag_id`) REFERENCES `x_tag` 
(`id`),
+CONSTRAINT `x_tag_res_map_FK_res_id` FOREIGN KEY (`res_id`) REFERENCES 
`x_service_resource` (`id`),
+CONSTRAINT `x_tag_res_map_FK_added_by_id` FOREIGN KEY (`added_by_id`) 
REFERENCES `x_portal_user` (`id`),
+CONSTRAINT `x_tag_res_map_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES 
`x_portal_user` (`id`)
+);
+-- -----------------------------------------------------
+-- Table `x_service_resource_element_val`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `x_service_resource_element_val` (
+`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
+`create_time` DATETIME DEFAULT NULL,
+`update_time` DATETIME DEFAULT NULL,
+`added_by_id` BIGINT(20) DEFAULT NULL,
+`upd_by_id` BIGINT(20) DEFAULT NULL,
+`res_element_id` BIGINT(20) NOT NULL,
+`value` VARCHAR(1024) NOT NULL,
+`sort_order` tinyint(3) DEFAULT '0',
+PRIMARY KEY (`id`),
+KEY `x_srvc_res_el_val_IDX_resel_id` (`res_element_id`),
+KEY `x_srvc_res_el_val_IDX_addby_id` (`added_by_id`),
+KEY `x_srvc_res_el_val_IDX_updby_id` (`upd_by_id`),
+CONSTRAINT `x_srvc_res_el_val_FK_res_el_id` FOREIGN KEY (`res_element_id`) 
REFERENCES `x_service_resource_element` (`id`),
+CONSTRAINT `x_srvc_res_el_val_FK_add_by_id` FOREIGN KEY (`added_by_id`) 
REFERENCES `x_portal_user` (`id`),
+CONSTRAINT `x_srvc_res_el_val_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) 
REFERENCES `x_portal_user` (`id`)
+);
 -- -------------------------------------
 -- add column in x_service_def.options
 -- -------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f08d5b36/security-admin/src/main/java/org/apache/ranger/biz/TagDBStore.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/biz/TagDBStore.java 
b/security-admin/src/main/java/org/apache/ranger/biz/TagDBStore.java
index ca15f98..6a5684b 100644
--- a/security-admin/src/main/java/org/apache/ranger/biz/TagDBStore.java
+++ b/security-admin/src/main/java/org/apache/ranger/biz/TagDBStore.java
@@ -922,7 +922,6 @@ public class TagDBStore extends AbstractTagStore {
                        for (RangerTagDef.RangerTagAttributeDef attrDef : 
tagAttrDefList) {
                                XXTagAttributeDef xAttrDef = new 
XXTagAttributeDef();
 
-                               xAttrDef.setGuid(guidUtil.genGUID());
                                xAttrDef.setTagDefId(tagDefId);
                                xAttrDef.setName(attrDef.getName());
                                xAttrDef.setType(attrDef.getType());
@@ -974,7 +973,6 @@ public class TagDBStore extends AbstractTagStore {
                                xTagAttr.setTagId(tagId);
                                xTagAttr.setName(attr.getKey());
                                xTagAttr.setValue(attr.getValue());
-                               xTagAttr.setGuid(guidUtil.genGUID());
                                xTagAttr = (XXTagAttribute) 
rangerAuditFields.populateAuditFieldsForCreate(xTagAttr);
 
                                xTagAttr = 
daoManager.getXXTagAttribute().create(xTagAttr);
@@ -1043,7 +1041,6 @@ public class TagDBStore extends AbstractTagStore {
                        
resourceElement.setIsRecursive(policyRes.getIsRecursive());
                        resourceElement.setResDefId(xResDef.getId());
                        resourceElement.setResourceId(resourceId);
-                       resourceElement.setGuid(guidUtil.genGUID());
 
                        resourceElement = (XXServiceResourceElement) 
rangerAuditFields.populateAuditFieldsForCreate(resourceElement);
 
@@ -1055,7 +1052,6 @@ public class TagDBStore extends AbstractTagStore {
                                
resourceElementValue.setResElementId(resourceElement.getId());
                                resourceElementValue.setValue(resVal);
                                resourceElementValue.setSortOrder(sortOrder);
-                               
resourceElementValue.setGuid(guidUtil.genGUID());
                                resourceElementValue = 
(XXServiceResourceElementValue) 
rangerAuditFields.populateAuditFieldsForCreate(resourceElementValue);
 
                                resourceElementValue = 
daoManager.getXXServiceResourceElementValue().create(resourceElementValue);

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f08d5b36/security-admin/src/main/java/org/apache/ranger/common/GUIDUtil.java
----------------------------------------------------------------------
diff --git 
a/security-admin/src/main/java/org/apache/ranger/common/GUIDUtil.java 
b/security-admin/src/main/java/org/apache/ranger/common/GUIDUtil.java
index 6710088..9c725c8 100644
--- a/security-admin/src/main/java/org/apache/ranger/common/GUIDUtil.java
+++ b/security-admin/src/main/java/org/apache/ranger/common/GUIDUtil.java
@@ -17,11 +17,10 @@
  * under the License.
  */
 
- package org.apache.ranger.common;
+package org.apache.ranger.common;
 
 import java.io.Serializable;
-import java.nio.ByteBuffer;
-import java.security.SecureRandom;
+import java.util.UUID;
 
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Service;
@@ -32,15 +31,11 @@ public class GUIDUtil implements Serializable {
        
        private static final long serialVersionUID = -7284237762948427019L;
 
-       static SecureRandom secureRandom = new 
SecureRandom(ByteBuffer.allocate(8).putLong(System.nanoTime()).array());
-       static int counter = 0;
-
        public String genGUID() {
-               return System.currentTimeMillis() + "_" + 
secureRandom.nextInt(1000)
-                               + "_" + counter++;
+               return UUID.randomUUID().toString();
        }
 
        public long genLong() {
-               return secureRandom.nextLong();
+               return UUID.randomUUID().getMostSignificantBits();
        }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f08d5b36/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResourceElement.java
----------------------------------------------------------------------
diff --git 
a/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResourceElement.java
 
b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResourceElement.java
index a545133..cd60736 100644
--- 
a/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResourceElement.java
+++ 
b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResourceElement.java
@@ -46,9 +46,6 @@ public class XXServiceResourceElement extends XXDBBase 
implements Serializable {
        @Column(name = "id")
        protected Long id;
 
-       @Column(name = "guid", unique = true, nullable = false, length = 512)
-       protected String guid;
-
        @Column(name = "res_def_id")
        protected Long resDefId;
 
@@ -72,21 +69,6 @@ public class XXServiceResourceElement extends XXDBBase 
implements Serializable {
        }
 
        /**
-        * @return the guid
-        */
-       public String getGuid() {
-               return guid;
-       }
-
-       /**
-        * @param guid
-        *            the guid to set
-        */
-       public void setGuid(String guid) {
-               this.guid = guid;
-       }
-
-       /**
         * @return the resDefId
         */
        public Long getResDefId() {
@@ -160,7 +142,6 @@ public class XXServiceResourceElement extends XXDBBase 
implements Serializable {
        public int hashCode() {
                final int prime = 31;
                int result = 1;
-               result = prime * result + ((guid == null) ? 0 : 
guid.hashCode());
                result = prime * result + ((id == null) ? 0 : id.hashCode());
                result = prime * result + ((isExcludes == null) ? 0 : 
isExcludes.hashCode());
                result = prime * result + ((isRecursive == null) ? 0 : 
isRecursive.hashCode());
@@ -183,11 +164,6 @@ public class XXServiceResourceElement extends XXDBBase 
implements Serializable {
                if (getClass() != obj.getClass())
                        return false;
                XXServiceResourceElement other = (XXServiceResourceElement) obj;
-               if (guid == null) {
-                       if (other.guid != null)
-                               return false;
-               } else if (!guid.equals(other.guid))
-                       return false;
                if (id == null) {
                        if (other.id != null)
                                return false;
@@ -232,7 +208,6 @@ public class XXServiceResourceElement extends XXDBBase 
implements Serializable {
                sb.append("{ ");
                sb.append(super.toString() + "} ");
                sb.append("id={").append(id).append("} ");
-               sb.append("guid={").append(guid).append("} ");
                sb.append("resDefId={").append(resDefId).append("} ");
                sb.append("resourceId={").append(resourceId).append("} ");
                sb.append("isExcludes={").append(isExcludes).append("} ");

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f08d5b36/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResourceElementValue.java
----------------------------------------------------------------------
diff --git 
a/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResourceElementValue.java
 
b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResourceElementValue.java
index 23b17b9..77c83ec 100644
--- 
a/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResourceElementValue.java
+++ 
b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResourceElementValue.java
@@ -35,7 +35,7 @@ import org.apache.ranger.common.AppConstants;
 
 @Entity
 @Cacheable
-@Table(name="x_service_resource_element_value")
+@Table(name="x_service_resource_element_val")
 @XmlRootElement
 public class XXServiceResourceElementValue extends XXDBBase implements 
Serializable {
        private static final long serialVersionUID = 1L;
@@ -46,9 +46,6 @@ public class XXServiceResourceElementValue extends XXDBBase 
implements Serializa
        @Column(name = "id")
        protected Long id;
 
-       @Column(name = "guid", unique = true, nullable = false, length = 512)
-       protected String guid;
-
        @Column(name = "res_element_id")
        protected Long resElementId;
 
@@ -69,21 +66,6 @@ public class XXServiceResourceElementValue extends XXDBBase 
implements Serializa
        }
 
        /**
-        * @return the guid
-        */
-       public String getGuid() {
-               return guid;
-       }
-
-       /**
-        * @param guid
-        *            the guid to set
-        */
-       public void setGuid(String guid) {
-               this.guid = guid;
-       }
-
-       /**
         * @return the resElementId
         */
        public Long getResElementId() {
@@ -142,7 +124,6 @@ public class XXServiceResourceElementValue extends XXDBBase 
implements Serializa
        public int hashCode() {
                final int prime = 31;
                int result = 1;
-               result = prime * result + ((guid == null) ? 0 : 
guid.hashCode());
                result = prime * result + ((id == null) ? 0 : id.hashCode());
                result = prime * result + ((resElementId == null) ? 0 : 
resElementId.hashCode());
                result = prime * result + ((sortOrder == null) ? 0 : 
sortOrder.hashCode());
@@ -164,11 +145,6 @@ public class XXServiceResourceElementValue extends 
XXDBBase implements Serializa
                if (getClass() != obj.getClass())
                        return false;
                XXServiceResourceElementValue other = 
(XXServiceResourceElementValue) obj;
-               if (guid == null) {
-                       if (other.guid != null)
-                               return false;
-               } else if (!guid.equals(other.guid))
-                       return false;
                if (id == null) {
                        if (other.id != null)
                                return false;
@@ -208,7 +184,6 @@ public class XXServiceResourceElementValue extends XXDBBase 
implements Serializa
                sb.append("{ ");
                sb.append(super.toString() + "} ");
                sb.append("id={").append(id).append("} ");
-               sb.append("guid={").append(guid).append("} ");
                sb.append("resElementId={").append(resElementId).append("} ");
                sb.append("value={").append(value).append("} ");
                sb.append("sortOrder={").append(sortOrder).append("} ");

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f08d5b36/security-admin/src/main/java/org/apache/ranger/entity/XXTagAttribute.java
----------------------------------------------------------------------
diff --git 
a/security-admin/src/main/java/org/apache/ranger/entity/XXTagAttribute.java 
b/security-admin/src/main/java/org/apache/ranger/entity/XXTagAttribute.java
index 3bb2207..cbbc102 100644
--- a/security-admin/src/main/java/org/apache/ranger/entity/XXTagAttribute.java
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXTagAttribute.java
@@ -46,16 +46,13 @@ public class XXTagAttribute extends XXDBBase implements 
Serializable {
        @Column(name = "id")
        protected Long id;
 
-       @Column(name = "guid", unique = true, nullable = false, length = 512)
-       protected String guid;
-
        @Column(name = "tag_id")
        protected Long tagId;
 
-       @Column(name = "attr_name")
+       @Column(name = "name")
        protected String name;
 
-       @Column(name = "attr_value")
+       @Column(name = "value")
        protected String value;
 
        @Override
@@ -69,21 +66,6 @@ public class XXTagAttribute extends XXDBBase implements 
Serializable {
        }
 
        /**
-        * @return the guid
-        */
-       public String getGuid() {
-               return guid;
-       }
-
-       /**
-        * @param guid
-        *            the guid to set
-        */
-       public void setGuid(String guid) {
-               this.guid = guid;
-       }
-
-       /**
         * @return the tagId
         */
        public Long getTagId() {
@@ -142,7 +124,6 @@ public class XXTagAttribute extends XXDBBase implements 
Serializable {
        public int hashCode() {
                final int prime = 31;
                int result = 1;
-               result = prime * result + ((guid == null) ? 0 : 
guid.hashCode());
                result = prime * result + ((id == null) ? 0 : id.hashCode());
                result = prime * result + ((name == null) ? 0 : 
name.hashCode());
                result = prime * result + ((tagId == null) ? 0 : 
tagId.hashCode());
@@ -164,11 +145,6 @@ public class XXTagAttribute extends XXDBBase implements 
Serializable {
                if (getClass() != obj.getClass())
                        return false;
                XXTagAttribute other = (XXTagAttribute) obj;
-               if (guid == null) {
-                       if (other.guid != null)
-                               return false;
-               } else if (!guid.equals(other.guid))
-                       return false;
                if (id == null) {
                        if (other.id != null)
                                return false;
@@ -208,7 +184,6 @@ public class XXTagAttribute extends XXDBBase implements 
Serializable {
                sb.append("{ ");
                sb.append(super.toString() + "} ");
                sb.append("id={").append(id).append("} ");
-               sb.append("guid={").append(guid).append("} ");
                sb.append("tagId={").append(tagId).append("} ");
                sb.append("name={").append(name).append("} ");
                sb.append("value={").append(value).append("} ");

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f08d5b36/security-admin/src/main/java/org/apache/ranger/entity/XXTagAttributeDef.java
----------------------------------------------------------------------
diff --git 
a/security-admin/src/main/java/org/apache/ranger/entity/XXTagAttributeDef.java 
b/security-admin/src/main/java/org/apache/ranger/entity/XXTagAttributeDef.java
index 4653481..acf6697 100644
--- 
a/security-admin/src/main/java/org/apache/ranger/entity/XXTagAttributeDef.java
+++ 
b/security-admin/src/main/java/org/apache/ranger/entity/XXTagAttributeDef.java
@@ -46,9 +46,6 @@ public class XXTagAttributeDef extends XXDBBase implements 
Serializable {
        @Column(name = "id")
        protected Long id;
 
-       @Column(name = "guid", unique = true, nullable = false, length = 512)
-       protected String guid;
-
        @Column(name = "tag_def_id")
        protected Long tagDefId;
 
@@ -69,21 +66,6 @@ public class XXTagAttributeDef extends XXDBBase implements 
Serializable {
        }
 
        /**
-        * @return the guid
-        */
-       public String getGuid() {
-               return guid;
-       }
-
-       /**
-        * @param guid
-        *            the guid to set
-        */
-       public void setGuid(String guid) {
-               this.guid = guid;
-       }
-
-       /**
         * @return the tagDefId
         */
        public Long getTagDefId() {
@@ -142,7 +124,6 @@ public class XXTagAttributeDef extends XXDBBase implements 
Serializable {
        public int hashCode() {
                final int prime = 31;
                int result = 1;
-               result = prime * result + ((guid == null) ? 0 : 
guid.hashCode());
                result = prime * result + ((id == null) ? 0 : id.hashCode());
                result = prime * result + ((name == null) ? 0 : 
name.hashCode());
                result = prime * result + ((tagDefId == null) ? 0 : 
tagDefId.hashCode());
@@ -164,11 +145,6 @@ public class XXTagAttributeDef extends XXDBBase implements 
Serializable {
                if (getClass() != obj.getClass())
                        return false;
                XXTagAttributeDef other = (XXTagAttributeDef) obj;
-               if (guid == null) {
-                       if (other.guid != null)
-                               return false;
-               } else if (!guid.equals(other.guid))
-                       return false;
                if (id == null) {
                        if (other.id != null)
                                return false;
@@ -208,7 +184,6 @@ public class XXTagAttributeDef extends XXDBBase implements 
Serializable {
                sb.append("{ ");
                sb.append(super.toString() + "} ");
                sb.append("id={").append(id).append("} ");
-               sb.append("guid={").append(guid).append("} ");
                sb.append("tagDefId={").append(tagDefId).append("} ");
                sb.append("name={").append(name).append("} ");
                sb.append("type={").append(type).append("} ");

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f08d5b36/security-admin/src/main/java/org/apache/ranger/service/RangerTagDefServiceBase.java
----------------------------------------------------------------------
diff --git 
a/security-admin/src/main/java/org/apache/ranger/service/RangerTagDefServiceBase.java
 
b/security-admin/src/main/java/org/apache/ranger/service/RangerTagDefServiceBase.java
index 1b4aa26..fe01e83 100644
--- 
a/security-admin/src/main/java/org/apache/ranger/service/RangerTagDefServiceBase.java
+++ 
b/security-admin/src/main/java/org/apache/ranger/service/RangerTagDefServiceBase.java
@@ -108,7 +108,6 @@ public abstract class RangerTagDefServiceBase<T extends 
XXTagDef, V extends Rang
 
                if (xTagAttrDef == null) {
                        xTagAttrDef = new XXTagAttributeDef();
-                       xTagAttrDef.setGuid(guidUtil.genGUID());
                }
 
                xTagAttrDef = (XXTagAttributeDef) 
rangerAuditFields.populateAuditFields(xTagAttrDef, parentObj);

Reply via email to