RANGER-595: Backend changes to support Tag based policies

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/bc090a66
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/bc090a66
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/bc090a66

Branch: refs/heads/tag-policy
Commit: bc090a66987b0421616802d5bc52e5567d5a030a
Parents: dba2bea
Author: Gautam Borad <[email protected]>
Authored: Tue Aug 11 15:17:16 2015 +0530
Committer: Madhan Neethiraj <[email protected]>
Committed: Tue Aug 11 08:12:19 2015 -0700

----------------------------------------------------------------------
 .../db/mysql/patches/009-updated_schema.sql     |   5 +-
 .../016-updated-schema-for-tag-based-policy.sql | 327 ++++++++++++
 .../audit/017-add-new-column-to-store-tags.sql  |  31 ++
 security-admin/db/mysql/xa_audit_db.sql         |   1 -
 security-admin/db/mysql/xa_core_db.sql          |   1 -
 .../java/org/apache/ranger/biz/TagDBStore.java  | 530 +++++++++++++++++++
 .../org/apache/ranger/common/AppConstants.java  |  34 +-
 .../apache/ranger/db/RangerDaoManagerBase.java  |  86 ++-
 .../org/apache/ranger/db/XXTagAttributeDao.java |  48 ++
 .../apache/ranger/db/XXTagAttributeDefDao.java  |  48 ++
 .../java/org/apache/ranger/db/XXTagDao.java     |  73 +++
 .../java/org/apache/ranger/db/XXTagDefDao.java  |  31 ++
 .../apache/ranger/db/XXTagResourceMapDao.java   |  48 ++
 .../apache/ranger/db/XXTaggedResourceDao.java   |  49 ++
 .../ranger/db/XXTaggedResourceValueDao.java     |  49 ++
 .../ranger/db/XXTaggedResourceValueMapDao.java  |  62 +++
 .../java/org/apache/ranger/entity/XXTag.java    | 220 ++++++++
 .../apache/ranger/entity/XXTagAttribute.java    | 220 ++++++++
 .../apache/ranger/entity/XXTagAttributeDef.java | 220 ++++++++
 .../java/org/apache/ranger/entity/XXTagDef.java | 245 +++++++++
 .../apache/ranger/entity/XXTagResourceMap.java  | 195 +++++++
 .../apache/ranger/entity/XXTaggedResource.java  | 245 +++++++++
 .../ranger/entity/XXTaggedResourceValue.java    | 245 +++++++++
 .../ranger/entity/XXTaggedResourceValueMap.java | 220 ++++++++
 .../java/org/apache/ranger/rest/TagREST.java    |  33 +-
 .../ranger/service/RangerAuditFields.java       |  12 +-
 .../ranger/service/RangerTagDefService.java     |  39 ++
 .../ranger/service/RangerTagDefServiceBase.java | 115 ++++
 .../service/RangerTaggedResourceService.java    |  43 ++
 .../RangerTaggedResourceServiceBase.java        | 147 +++++
 .../resources/META-INF/jpa_named_queries.xml    |  47 ++
 31 files changed, 3639 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/bc090a66/security-admin/db/mysql/patches/009-updated_schema.sql
----------------------------------------------------------------------
diff --git a/security-admin/db/mysql/patches/009-updated_schema.sql 
b/security-admin/db/mysql/patches/009-updated_schema.sql
index b0f8432..d533bf3 100644
--- a/security-admin/db/mysql/patches/009-updated_schema.sql
+++ b/security-admin/db/mysql/patches/009-updated_schema.sql
@@ -29,7 +29,6 @@ CREATE TABLE `x_service_def` (
 `impl_class_name` varchar(1024) DEFAULT NULL,
 `label` varchar(1024) DEFAULT NULL,
 `description` varchar(1024) DEFAULT NULL,
-`options` varchar(1024) DEFAULT NULL,
 `rb_key_label` varchar(1024) DEFAULT NULL,
 `rb_key_description` varchar(1024) DEFAULT NULL,
 `is_enabled` tinyint DEFAULT 1,
@@ -58,7 +57,6 @@ CREATE TABLE `x_service` (
 `policy_update_time`datetime DEFAULT NULL,
 `description` varchar(1024) DEFAULT NULL,
 `is_enabled` tinyint(1) NOT NULL DEFAULT '0',   
-`tag_service` bigint(20) DEFAULT NULL,
 primary key (`id`),
 UNIQUE KEY `X_service_name` (`name`),
 KEY `x_service_added_by_id` (`added_by_id`),
@@ -68,8 +66,7 @@ KEY `x_service_up_time` (`update_time`),
 KEY `x_service_type` (`type`),  
 CONSTRAINT `x_service_FK_added_by_id` FOREIGN KEY (`added_by_id`) REFERENCES 
`x_portal_user` (`id`),
 CONSTRAINT `x_service_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES 
`x_portal_user` (`id`),
-CONSTRAINT `x_service_FK_type` FOREIGN KEY (`type`) REFERENCES `x_service_def` 
(`id`),
-CONSTRAINT `x_service_FK_tag_service` FOREIGN KEY (`tag_service`) REFERENCES 
`x_service` (`id`)
+CONSTRAINT `x_service_FK_type` FOREIGN KEY (`type`) REFERENCES `x_service_def` 
(`id`)
 );
 
 DROP TABLE IF EXISTS `x_policy`;

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/bc090a66/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
new file mode 100644
index 0000000..4f6fe02
--- /dev/null
+++ 
b/security-admin/db/mysql/patches/016-updated-schema-for-tag-based-policy.sql
@@ -0,0 +1,327 @@
+-- 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.
+
+-- Temporary table structure for view `vx_trx_log`
+--
+
+-- -----------------------------------------------------
+-- Table `x_tag_def`
+-- -----------------------------------------------------
+DROP TABLE IF EXISTS `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),
+  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)
+ENGINE = InnoDB;
+
+
+-- -----------------------------------------------------
+-- Table `x_tag`
+-- -----------------------------------------------------
+DROP TABLE IF EXISTS `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,
+  `tag_def_id` BIGINT(20) NULL,
+  `external_id` VARCHAR(512) NULL,
+  `name` VARCHAR(512) NOT NULL,
+  PRIMARY KEY (`id`),
+  INDEX `fk_X_TAG_DEF_ID` (`tag_def_id` ASC),
+  INDEX `fk_X_TAG_ADDED_BY_ID` (`added_by_id` ASC),
+  INDEX `fk_X_TAG_UPD_BY_ID` (`upd_by_id` ASC),
+  KEY `external_id` (`external_id`),
+  CONSTRAINT `fk_X_TAG_DEF_ID`
+    FOREIGN KEY (`tag_def_id`)
+    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)
+ENGINE = InnoDB;
+
+
+
+-- -----------------------------------------------------
+-- Table `x_tagged_resource`
+-- -----------------------------------------------------
+DROP TABLE IF EXISTS `x_tagged_resource` ;
+
+CREATE TABLE IF NOT EXISTS `x_tagged_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,
+  `external_id` VARCHAR(512) NULL,
+  `service_id` BIGINT(20) NOT NULL,
+  `is_enabled` TINYINT NULL DEFAULT 1,
+  PRIMARY KEY (`id`),
+  INDEX `fk_X_TAGGED_RESOURCE_ADDED_BY_ID` (`added_by_id` ASC),
+  INDEX `fk_X_TAGGED_RESOURCE_UPD_BY_ID` (`upd_by_id` ASC),
+  KEY `external_id` (`external_id`),
+  CONSTRAINT `fk_X_TAGGED_RESOURCE_SERVICE_ID`
+    FOREIGN KEY (`service_id`)
+    REFERENCES `x_service` (`id`)
+    ON DELETE RESTRICT
+    ON UPDATE RESTRICT,
+  CONSTRAINT `fk_X_TAGGED_RESOURCE_ADDED_BY_ID`
+    FOREIGN KEY (`added_by_id`)
+    REFERENCES `x_portal_user` (`id`)
+    ON DELETE RESTRICT
+    ON UPDATE RESTRICT,
+  CONSTRAINT `fk_X_TAGGED_RESOURCE_UPD_BY_ID`
+    FOREIGN KEY (`upd_by_id`)
+    REFERENCES `x_portal_user` (`id`)
+    ON DELETE RESTRICT
+    ON UPDATE RESTRICT)
+ENGINE = InnoDB;
+
+
+-- -----------------------------------------------------
+-- Table `x_tagged_resource_value`
+-- -----------------------------------------------------
+DROP TABLE IF EXISTS `x_tagged_resource_value` ;
+
+CREATE TABLE IF NOT EXISTS `x_tagged_resource_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,
+  `tagged_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_TAGGED_RESOURCE_VALUE_ADDED_BY_ID` (`added_by_id` ASC),
+  INDEX `fk_X_TAGGED_RESOURCE_VALUE_UPD_BY_ID` (`upd_by_id` ASC),
+  CONSTRAINT `fk_X_TAGGED_RESOURCE_VALUE_res_def_id` 
+    FOREIGN KEY (`res_def_id`) 
+    REFERENCES `x_resource_def` (`id`)
+    ON DELETE RESTRICT
+    ON UPDATE RESTRICT,
+  CONSTRAINT `fk_X_TAGGED_RESOURCE_VALUE_tagged_res_id` 
+    FOREIGN KEY (`tagged_res_id`) 
+    REFERENCES `x_tagged_resource` (`id`)
+    ON DELETE RESTRICT
+    ON UPDATE RESTRICT,
+  CONSTRAINT `fk_X_TAGGED_RESOURCE_VALUE_ADDED_BY_ID`
+    FOREIGN KEY (`added_by_id`)
+    REFERENCES `x_portal_user` (`id`)
+    ON DELETE RESTRICT
+    ON UPDATE RESTRICT,
+  CONSTRAINT `fk_X_TAGGED_RESOURCE_VALUE_UPD_BY_ID`
+    FOREIGN KEY (`upd_by_id`)
+    REFERENCES `x_portal_user` (`id`)
+    ON DELETE RESTRICT
+    ON UPDATE RESTRICT)
+ENGINE = InnoDB;
+
+-- -----------------------------------------------------
+-- Table `x_tag_attr_def`
+-- -----------------------------------------------------
+DROP TABLE IF EXISTS `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)
+ENGINE = InnoDB;
+
+
+-- -----------------------------------------------------
+-- Table `x_tag_attr`
+-- -----------------------------------------------------
+DROP TABLE IF EXISTS `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)
+ENGINE = InnoDB;
+
+
+-- -----------------------------------------------------
+-- Table `x_tag_resource_map`
+-- -----------------------------------------------------
+DROP TABLE IF EXISTS `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,
+  `tagged_res_id` BIGINT(20) NOT NULL,
+  PRIMARY KEY (`id`),
+  INDEX `fk_X_TAG_ID` (`tag_id` ASC),
+  INDEX `fk_X_TAGGED_RES_ID` (`tagged_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_TAGGED_RES_ID`
+    FOREIGN KEY (`tagged_res_id`)
+    REFERENCES `x_tagged_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)
+ENGINE = InnoDB;
+
+
+-- -----------------------------------------------------
+-- Table `x_tagged_resource_value_map`
+-- -----------------------------------------------------
+DROP TABLE IF EXISTS `x_tagged_resource_value_map` ;
+
+CREATE TABLE IF NOT EXISTS `x_tagged_resource_value_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,
+  `res_value_id` BIGINT(20) NOT NULL,
+  `value` VARCHAR(512) NOT NULL,
+  `sort_order` INT NULL,
+  PRIMARY KEY (`id`),
+  INDEX `fk_X_RESOURCE_VALUE_ID` (`res_value_id` ASC),
+  INDEX `fk_X_TAGGED_RES_VAL_MAP_ADDED_BY_ID` (`added_by_id` ASC),
+  INDEX `fk_X_TAGGED_RES_VAL_MAP_UPD_BY_ID` (`upd_by_id` ASC),
+  CONSTRAINT `fk_X_RESOURCE_VALUE_ID`
+    FOREIGN KEY (`res_value_id`)
+    REFERENCES `x_tagged_resource_value` (`id`)
+    ON DELETE RESTRICT
+    ON UPDATE RESTRICT,
+  CONSTRAINT `fk_X_TAGGED_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_TAGGED_RES_VAL_MAP_UPD_BY_ID`
+    FOREIGN KEY (`upd_by_id`)
+    REFERENCES `x_portal_user` (`id`)
+    ON DELETE RESTRICT
+    ON UPDATE RESTRICT)
+ENGINE = InnoDB;
+
+
+-- ----------------------------------------------------------------
+-- ranger database add column in x_service_def and x_service table
+-- ----------------------------------------------------------------
+alter table x_service_def add column `options` VARCHAR(1024) DEFAULT NULL NULL;
+alter table x_service add column `tag_service` BIGINT DEFAULT NULL NULL;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/bc090a66/security-admin/db/mysql/patches/audit/017-add-new-column-to-store-tags.sql
----------------------------------------------------------------------
diff --git 
a/security-admin/db/mysql/patches/audit/017-add-new-column-to-store-tags.sql 
b/security-admin/db/mysql/patches/audit/017-add-new-column-to-store-tags.sql
new file mode 100644
index 0000000..20353ba
--- /dev/null
+++ b/security-admin/db/mysql/patches/audit/017-add-new-column-to-store-tags.sql
@@ -0,0 +1,31 @@
+-- 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 add_column_in_xa_access_audit_table;
+
+delimiter ;;
+create procedure add_column_in_xa_access_audit_table() begin
+
+ /* Add new column `tags` in table */
+ if exists (select * from information_schema.columns where 
table_schema=database() and table_name = 'xa_access_audit' and column_name = 
'tags' and data_type='varchar') then
+       alter table xa_access_audit add column `tags` VARCHAR(4000) DEFAULT 
NULL NULL;
+ end if;
+
+end;;
+
+delimiter ;
+call add_column_in_xa_access_audit_table();
+
+drop procedure if exists add_column_in_xa_access_audit_table;

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/bc090a66/security-admin/db/mysql/xa_audit_db.sql
----------------------------------------------------------------------
diff --git a/security-admin/db/mysql/xa_audit_db.sql 
b/security-admin/db/mysql/xa_audit_db.sql
index 29e4718..8334dce 100644
--- a/security-admin/db/mysql/xa_audit_db.sql
+++ b/security-admin/db/mysql/xa_audit_db.sql
@@ -61,7 +61,6 @@ CREATE TABLE `xa_access_audit` (
   `request_data` varchar(4000) DEFAULT NULL,
   `resource_path` varchar(4000) DEFAULT NULL,
   `resource_type` varchar(255) DEFAULT NULL,
-  `tags` varchar(4000) DEFAULT NULL,
 
   PRIMARY KEY (`id`),
   KEY `xa_access_audit_added_by_id` (`added_by_id`),

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/bc090a66/security-admin/db/mysql/xa_core_db.sql
----------------------------------------------------------------------
diff --git a/security-admin/db/mysql/xa_core_db.sql 
b/security-admin/db/mysql/xa_core_db.sql
index e9de53d..9d889a0 100644
--- a/security-admin/db/mysql/xa_core_db.sql
+++ b/security-admin/db/mysql/xa_core_db.sql
@@ -706,7 +706,6 @@ CREATE TABLE `xa_access_audit` (
   `request_data` varchar(2000) DEFAULT NULL,
   `resource_path` varchar(2000) DEFAULT NULL,
   `resource_type` varchar(255) DEFAULT NULL,
-  `tags` varchar(2000) DEFAULT NULL,
   PRIMARY KEY (`id`),
   KEY `xa_access_audit_added_by_id` (`added_by_id`),
   KEY `xa_access_audit_upd_by_id` (`upd_by_id`),

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/bc090a66/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
new file mode 100644
index 0000000..c424425
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/biz/TagDBStore.java
@@ -0,0 +1,530 @@
+/*
+ * 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.
+ */
+
+package org.apache.ranger.biz;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ranger.common.GUIDUtil;
+import org.apache.ranger.common.MessageEnums;
+import org.apache.ranger.common.RESTErrorUtil;
+import org.apache.ranger.db.RangerDaoManager;
+import org.apache.ranger.entity.XXDBBase;
+import org.apache.ranger.entity.XXResourceDef;
+import org.apache.ranger.entity.XXService;
+import org.apache.ranger.entity.XXServiceDef;
+import org.apache.ranger.entity.XXTag;
+import org.apache.ranger.entity.XXTagAttribute;
+import org.apache.ranger.entity.XXTagResourceMap;
+import org.apache.ranger.entity.XXTaggedResource;
+import org.apache.ranger.entity.XXTaggedResourceValue;
+import org.apache.ranger.entity.XXTaggedResourceValueMap;
+import org.apache.ranger.plugin.model.RangerPolicy;
+import org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyResource;
+import org.apache.ranger.plugin.model.RangerServiceDef;
+import org.apache.ranger.plugin.model.RangerTagDef;
+import org.apache.ranger.plugin.model.RangerTaggedResource;
+import org.apache.ranger.plugin.model.RangerTaggedResource.RangerResourceTag;
+import org.apache.ranger.plugin.model.RangerTaggedResourceKey;
+import 
org.apache.ranger.plugin.policyresourcematcher.RangerDefaultPolicyResourceMatcher;
+import org.apache.ranger.plugin.store.PList;
+import org.apache.ranger.plugin.store.ServiceStore;
+import org.apache.ranger.plugin.store.TagStore;
+import org.apache.ranger.plugin.util.SearchFilter;
+import org.apache.ranger.plugin.util.TagServiceResources;
+import org.apache.ranger.service.RangerAuditFields;
+import org.apache.ranger.service.RangerTagDefService;
+import org.apache.ranger.service.RangerTaggedResourceService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class TagDBStore implements TagStore {
+       private static final Log LOG = LogFactory.getLog(TagDBStore.class);
+
+       @Autowired
+       RangerTagDefService rangerTagDefService;
+
+       @Autowired
+       RangerTaggedResourceService rangerTaggedResourceService;
+
+       @Autowired
+       RangerDaoManager daoManager;
+
+       @Autowired
+       RESTErrorUtil errorUtil;
+
+       @Autowired
+       RangerAuditFields<XXDBBase> rangerAuditFields;
+
+       @Autowired
+       GUIDUtil guidUtil;
+
+       @Autowired
+       ServiceDBStore serviceDBStore;
+
+       @Override
+       public void init() throws Exception {
+
+       }
+
+       @Override
+       public void setServiceStore(ServiceStore svcStore) {
+
+       }
+
+       @Override
+       public RangerTagDef createTagDef(RangerTagDef tagDef) throws Exception {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       @Override
+       public RangerTagDef updateTagDef(RangerTagDef TagDef) throws Exception {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       @Override
+       public void deleteTagDef(String name) throws Exception {
+               // TODO Auto-generated method stub
+
+       }
+
+       @Override
+       public RangerTagDef getTagDef(String name) throws Exception {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       @Override
+       public RangerTagDef getTagDefById(Long id) throws Exception {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       @Override
+       public List<RangerTagDef> getTagDefs(SearchFilter filter) throws 
Exception {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       @Override
+       public PList<RangerTagDef> getPaginatedTagDefs(SearchFilter filter) 
throws Exception {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       @Override
+       public RangerTaggedResource createTaggedResource(RangerTaggedResource 
resource, boolean createOrUpdate) throws Exception {
+               if (LOG.isDebugEnabled()) {
+                       LOG.debug("==> TagDBStore.createTaggedResource(" + 
resource + ")");
+               }
+
+               RangerTaggedResource ret = null;
+               RangerTaggedResource existing = null;
+               boolean updateResource = false;
+
+               existing = getResource(resource.getKey());
+
+               if (existing != null) {
+                       if (!createOrUpdate) {
+                               throw 
errorUtil.createRESTException("resource(s) with same specification already 
exists", MessageEnums.ERROR_DUPLICATE_OBJECT);
+                       } else {
+                               updateResource = true;
+                       }
+               }
+
+               if (!updateResource) {
+                       if (resource.getId() != null) {
+                               existing = getResource(resource.getId());
+                       }
+
+                       if (existing != null) {
+                               if (!createOrUpdate) {
+                                       throw 
errorUtil.createRESTException(resource.getId() + ": resource already exists 
(id=" + existing.getId() + ")", MessageEnums.ERROR_DUPLICATE_OBJECT);
+                               } else {
+                                       updateResource = true;
+                               }
+                       }
+               }
+
+               try {
+                       if (updateResource) {
+                               ret = updateTaggedResource(resource);
+                       } else {
+                               ret = 
rangerTaggedResourceService.create(resource);
+
+                               ret.setKey(resource.getKey());
+                               ret.setTags(resource.getTags());
+                               RangerTaggedResourceKey resKey = 
createResourceSpecForTaggedResource(ret);
+                               List<RangerResourceTag> tags = 
createTagsForTaggedResource(ret);
+
+                               if (resKey == null || tags == null) {
+                                       throw 
errorUtil.createRESTException("failed to save resource '" + resource.getId() + 
"'", MessageEnums.ERROR_CREATING_OBJECT);
+                               }
+                       }
+               } catch (Exception excp) {
+                       LOG.warn("TagDBStore.createTaggedResource: failed to 
save resource '" + resource.getId() + "'", excp);
+                       throw errorUtil.createRESTException("failed to save 
resource '" + resource.getId() + "'", MessageEnums.ERROR_CREATING_OBJECT);
+               }
+
+               if (LOG.isDebugEnabled()) {
+                       LOG.debug("<== TagDBStore.createTaggedResource(" + 
resource + ")");
+               }
+               return ret;
+       }
+
+       private List<RangerResourceTag> 
createTagsForTaggedResource(RangerTaggedResource resource) {
+
+               List<RangerResourceTag> tags = resource.getTags();
+
+               if (tags == null) {
+                       return null;
+               }
+
+               for (RangerResourceTag tag : tags) {
+                       XXTag xTag = new XXTag();
+
+                       xTag.setExternalId(tag.getExternalId());
+                       xTag.setName(tag.getName());
+                       xTag.setGuid(guidUtil.genGUID());
+                       xTag = (XXTag) 
rangerAuditFields.populateAuditFieldsForCreate(xTag);
+
+                       xTag = daoManager.getXXTag().create(xTag);
+
+                       for (Entry<String, String> attr : 
tag.getAttributeValues().entrySet()) {
+                               XXTagAttribute xTagAttr = new XXTagAttribute();
+
+                               xTagAttr.setTagId(xTag.getId());
+                               xTagAttr.setName(attr.getKey());
+                               xTagAttr.setValue(attr.getValue());
+                               xTagAttr.setGuid(guidUtil.genGUID());
+                               xTagAttr = (XXTagAttribute) 
rangerAuditFields.populateAuditFieldsForCreate(xTagAttr);
+
+                               xTagAttr = 
daoManager.getXXTagAttribute().create(xTagAttr);
+                       }
+
+                       XXTagResourceMap tagResMap = new XXTagResourceMap();
+                       tagResMap.setTaggedResId(resource.getId());
+                       tagResMap.setTagId(xTag.getId());
+                       tagResMap.setGuid(guidUtil.genGUID());
+                       tagResMap = (XXTagResourceMap) 
rangerAuditFields.populateAuditFieldsForCreate(tagResMap);
+
+                       tagResMap = 
daoManager.getXXTagResourceMap().create(tagResMap);
+               }
+
+               return tags;
+       }
+
+       private RangerTaggedResourceKey 
createResourceSpecForTaggedResource(RangerTaggedResource resource) {
+
+               if (resource.getKey() == null) {
+                       return null;
+               }
+
+               String serviceName = resource.getKey().getServiceName();
+
+               XXService xService = 
daoManager.getXXService().findByName(serviceName);
+               if (xService == null) {
+                       throw errorUtil.createRESTException("No Service found 
with name: " + serviceName, MessageEnums.ERROR_CREATING_OBJECT);
+               }
+
+               XXServiceDef xServiceDef = 
daoManager.getXXServiceDef().getById(xService.getType());
+               if (xServiceDef == null) {
+                       throw errorUtil.createRESTException("No Service-Def 
found with ID: " + xService.getType(), MessageEnums.ERROR_CREATING_OBJECT);
+               }
+
+               RangerTaggedResourceKey resKey = resource.getKey();
+               Map<String, RangerPolicy.RangerPolicyResource> resourceSpec = 
resKey.getResourceSpec();
+
+               for (Entry<String, RangerPolicyResource> resSpec : 
resourceSpec.entrySet()) {
+                       XXResourceDef xResDef = 
daoManager.getXXResourceDef().findByNameAndServiceDefId(resSpec.getKey(), 
xServiceDef.getId());
+
+                       if (xResDef == null) {
+                               LOG.error("TagDBStore.createTaggedResource: 
ResourceType is not valid [" + resSpec.getKey() + "]");
+                               throw errorUtil.createRESTException("Resource 
Type is not valid [" + resSpec.getKey() + "]", MessageEnums.DATA_NOT_FOUND);
+                       }
+
+                       RangerPolicyResource policyRes = resSpec.getValue();
+
+                       XXTaggedResourceValue taggedResValue = new 
XXTaggedResourceValue();
+                       taggedResValue.setIsExcludes(policyRes.getIsExcludes());
+                       
taggedResValue.setIsRecursive(policyRes.getIsRecursive());
+                       taggedResValue.setResDefId(xResDef.getId());
+                       taggedResValue.setTaggedResourceId(resource.getId());
+                       taggedResValue.setGuid(guidUtil.genGUID());
+
+                       taggedResValue = (XXTaggedResourceValue) 
rangerAuditFields.populateAuditFieldsForCreate(taggedResValue);
+
+                       taggedResValue = 
daoManager.getXXTaggedResourceValue().create(taggedResValue);
+
+                       int sortOrder = 1;
+                       for (String resVal : policyRes.getValues()) {
+                               XXTaggedResourceValueMap taggedResValueMap = 
new XXTaggedResourceValueMap();
+                               
taggedResValueMap.setResValueId(taggedResValue.getId());
+                               taggedResValueMap.setValue(resVal);
+                               taggedResValueMap.setSortOrder(sortOrder);
+                               taggedResValueMap.setGuid(guidUtil.genGUID());
+                               taggedResValueMap = (XXTaggedResourceValueMap) 
rangerAuditFields.populateAuditFieldsForCreate(taggedResValueMap);
+
+                               taggedResValueMap = 
daoManager.getXXTaggedResourceValueMap().create(taggedResValueMap);
+                               sortOrder++;
+                       }
+               }
+               return resKey;
+       }
+
+       @Override
+       public RangerTaggedResource updateTaggedResource(RangerTaggedResource 
resource) throws Exception {
+
+               RangerTaggedResource existing = getResource(resource.getId());
+               if (existing == null) {
+                       throw errorUtil.createRESTException(resource.getId() + 
": resource does not exist (id=" + resource.getId() + ")", 
MessageEnums.DATA_NOT_FOUND);
+               }
+
+               RangerTaggedResource ret = null;
+
+               try {
+                       if (StringUtils.isEmpty(resource.getCreatedBy())) {
+                               resource.setCreatedBy(existing.getCreatedBy());
+                       }
+                       if (resource.getCreateTime() == null) {
+                               
resource.setCreateTime(existing.getCreateTime());
+                       }
+
+                       ret = rangerTaggedResourceService.update(resource);
+                       ret.setTags(resource.getTags());
+                       ret.setKey(resource.getKey());
+
+                       RangerTaggedResourceKey updKey = 
updateResourceSpecForTaggedResource(ret);
+                       List<RangerResourceTag> updTags = 
updateTagsForTaggedResource(ret);
+
+                       ret.setKey(updKey);
+                       ret.setTags(updTags);
+
+               } catch (Exception excp) {
+                       LOG.warn("TagDBStore.updateTagDef(): failed to save 
resource '" + resource.getId() + "'", excp);
+
+                       throw new Exception("failed to save resource '" + 
resource.getId() + "'", excp);
+               }
+
+               return ret;
+       }
+
+       private RangerTaggedResourceKey 
updateResourceSpecForTaggedResource(RangerTaggedResource updResource) {
+
+               if (updResource == null) {
+                       return null;
+               }
+
+               deleteTaggedResourceValue(updResource.getId());
+
+               return createResourceSpecForTaggedResource(updResource);
+       }
+
+       private List<RangerResourceTag> 
updateTagsForTaggedResource(RangerTaggedResource updResource) {
+
+               if (updResource == null) {
+                       return null;
+               }
+
+               deleteTagsForTaggedResource(updResource.getId());
+
+               return createTagsForTaggedResource(updResource);
+       }
+
+       private void deleteTaggedResourceValue(Long resourceId) {
+               List<XXTaggedResourceValue> taggedResValueList = 
daoManager.getXXTaggedResourceValue().findByTaggedResId(resourceId);
+               for (XXTaggedResourceValue taggedResValue : taggedResValueList) 
{
+                       List<XXTaggedResourceValueMap> taggedResValueMapList = 
daoManager.getXXTaggedResourceValueMap().findByResValueId(taggedResValue.getId());
+                       for (XXTaggedResourceValueMap taggedResValueMap : 
taggedResValueMapList) {
+                               
daoManager.getXXTaggedResourceValueMap().remove(taggedResValueMap);
+                       }
+                       
daoManager.getXXTaggedResourceValue().remove(taggedResValue);
+               }
+       }
+
+       private void deleteTagsForTaggedResource(Long resourceId) {
+               List<XXTagResourceMap> oldTagResMapList = 
daoManager.getXXTagResourceMap().findByTaggedResourceId(resourceId);
+               for (XXTagResourceMap oldTagResMap : oldTagResMapList) {
+                       daoManager.getXXTagResourceMap().remove(oldTagResMap);
+
+                       List<XXTagAttribute> tagAttrList = 
daoManager.getXXTagAttribute().findByTagId(oldTagResMap.getTagId());
+                       for (XXTagAttribute tagAttr : tagAttrList) {
+                               daoManager.getXXTagAttribute().remove(tagAttr);
+                       }
+                       daoManager.getXXTag().remove(oldTagResMap.getTagId());
+               }
+       }
+
+       @Override
+       public void deleteResource(Long taggedResId) throws Exception {
+
+               XXTaggedResource taggedRes = 
daoManager.getXXTaggedResource().getById(taggedResId);
+               if (taggedRes == null) {
+                       throw errorUtil.createRESTException("No Resource exists 
with Id: " + taggedResId, MessageEnums.DATA_NOT_FOUND);
+               }
+
+               // Remove tags associated with resource
+               deleteTagsForTaggedResource(taggedResId);
+
+               // Remove taggedResourceValue
+               deleteTaggedResourceValue(taggedResId);
+
+               // Remove taggedResource
+               daoManager.getXXTaggedResource().remove(taggedRes);
+       }
+
+       @Override
+       public RangerTaggedResource getResource(Long id) throws Exception {
+               return rangerTaggedResourceService.read(id);
+       }
+
+       @Override
+       public TagServiceResources getResources(String serviceName, Long 
lastTimestamp) throws Exception {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       @Override
+       public List<RangerTaggedResource> getResources(SearchFilter filter) 
throws Exception {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       @Override
+       public PList<RangerTaggedResource> getPaginatedResources(SearchFilter 
filter) throws Exception {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       @Override
+       public List<String> getTags(String serviceName) throws Exception {
+
+               XXService xService = 
daoManager.getXXService().findByName(serviceName);
+               if (xService == null) {
+                       throw errorUtil.createRESTException("No Service found 
with name [" + serviceName + "]", MessageEnums.DATA_NOT_FOUND);
+               }
+
+               List<String> tagList = 
daoManager.getXXTag().findTagNamesByServiceId(xService.getId());
+
+               Collections.sort(tagList, new Comparator<String>() {
+                       @Override
+                       public int compare(String s1, String s2) {
+                               return s1.compareToIgnoreCase(s2);
+                       }
+               });
+
+               return tagList;
+       }
+
+       @Override
+       public List<String> lookupTags(String serviceName, String 
tagNamePattern) throws Exception {
+
+               if (LOG.isDebugEnabled()) {
+                       LOG.debug("==> TagDBStore.lookupTags(" + serviceName + 
", " + tagNamePattern + ")");
+               }
+
+               List<String> tagNameList = getTags(serviceName);
+               List<String> matchedTagList = new ArrayList<String>();
+
+               if (CollectionUtils.isNotEmpty(tagNameList)) {
+                       Pattern p = Pattern.compile(tagNamePattern);
+                       for (String tagName : tagNameList) {
+                               Matcher m = p.matcher(tagName);
+                               if (LOG.isDebugEnabled()) {
+                                       LOG.debug("TagDBStore.lookupTags) - 
Trying to match .... tagNamePattern=" + tagNamePattern + ", tagName=" + 
tagName);
+                               }
+                               if (m.matches()) {
+                                       if (LOG.isDebugEnabled()) {
+                                               
LOG.debug("TagDBStore.lookupTags) - Match found.... tagNamePattern=" + 
tagNamePattern + ", tagName=" + tagName);
+                                       }
+                                       matchedTagList.add(tagName);
+                               }
+                       }
+               }
+
+               if (LOG.isDebugEnabled()) {
+                       LOG.debug("<== TagDBStore.lookupTags(" + serviceName + 
", " + tagNamePattern + ")");
+               }
+
+               return matchedTagList;
+       }
+
+       @Override
+       public RangerTaggedResource getResource(RangerTaggedResourceKey key) 
throws Exception {
+               if (key == null) {
+                       LOG.error("TagDBStore.getResources() - parameter 'key' 
is null.");
+                       throw 
errorUtil.createRESTException("TagFileStore.getResources() - parameter 'key' is 
null.", MessageEnums.INVALID_INPUT_DATA);
+               }
+
+               XXService xService = 
daoManager.getXXService().findByName(key.getServiceName());
+               if (xService == null) {
+                       LOG.error("TagDBStore.getResources() - No Service found 
with name [" + key.getServiceName() + "]");
+                       throw 
errorUtil.createRESTException("TagDBStore.getResources() - No Service found 
with name [" + key.getServiceName() + "]", MessageEnums.INVALID_INPUT_DATA);
+               }
+
+               RangerServiceDef serviceDef = 
serviceDBStore.getServiceDef(xService.getType());
+
+               Long serviceId = xService.getId();
+
+               RangerTaggedResource ret = null;
+
+               List<XXTaggedResource> taggedResList = 
daoManager.getXXTaggedResource().findByServiceId(serviceId);
+
+               if (CollectionUtils.isEmpty(taggedResList)) {
+                       return null;
+               }
+
+               if (taggedResList.size() == 1) {
+                       ret = 
rangerTaggedResourceService.getPopulatedViewObjject(taggedResList.get(0));
+                       return ret;
+               } else {
+                       for (XXTaggedResource xTaggedRes : taggedResList) {
+                               RangerTaggedResource taggedRes = 
rangerTaggedResourceService.getPopulatedViewObjject(xTaggedRes);
+
+                               RangerDefaultPolicyResourceMatcher 
policyResourceMatcher = new RangerDefaultPolicyResourceMatcher();
+
+                               
policyResourceMatcher.setPolicyResources(taggedRes.getKey().getResourceSpec());
+
+                               policyResourceMatcher.setServiceDef(serviceDef);
+                               policyResourceMatcher.init();
+                               boolean isMatch = 
policyResourceMatcher.isExactMatch(key.getResourceSpec());
+
+                               if (isMatch) {
+                                       return taggedRes;
+                               }
+                       }
+               }
+               return ret;
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/bc090a66/security-admin/src/main/java/org/apache/ranger/common/AppConstants.java
----------------------------------------------------------------------
diff --git 
a/security-admin/src/main/java/org/apache/ranger/common/AppConstants.java 
b/security-admin/src/main/java/org/apache/ranger/common/AppConstants.java
index 491726f..0fb5c31 100644
--- a/security-admin/src/main/java/org/apache/ranger/common/AppConstants.java
+++ b/security-admin/src/main/java/org/apache/ranger/common/AppConstants.java
@@ -542,11 +542,43 @@ public class AppConstants extends RangerCommonEnums {
         * CLASS_TYPE_RANGER_SERVICE_DEF_WITH_ASSIGNED_ID is an element of enum 
ClassTypes. Its value is "CLASS_TYPE_RANGER_SERVICE_DEF_WITH_ASSIGNED_ID".
         */
        public static final int CLASS_TYPE_RANGER_SERVICE_DEF_WITH_ASSIGNED_ID 
= 1040;
+       /**
+        * Class type of XXTagDef
+        */
+       public static final int CLASS_TYPE_XA_TAG_DEF = 1041;
+       /**
+        * Class type of XXTagAttributeDef
+        */
+       public static final int CLASS_TYPE_XA_TAG_ATTR_DEF = 1042;
+       /**
+        * Class type of XXTaggedResource
+        */
+       public static final int CLASS_TYPE_XA_TAGGED_RESOURCE = 1043;
+       /**
+        * Class type of XXTaggedResourceValue
+        */
+       public static final int CLASS_TYPE_XA_TAGGED_RESOURCE_VALUE = 1044;
+       /**
+        * Class type of XXTaggedResourceValueMap
+        */
+       public static final int CLASS_TYPE_XA_TAGGED_RESOURCE_VALUE_MAP = 1045;
+       /**
+        * Class type of XXTag
+        */
+       public static final int CLASS_TYPE_XA_TAG = 1046;
+       /**
+        * Class type of XXTagAttribute
+        */
+       public static final int CLASS_TYPE_XA_TAG_ATTR = 1047;
+       /**
+        * Class type of XXTagResourceMap
+        */
+       public static final int CLASS_TYPE_XA_TAG_RESOURCE_MAP = 1048;
 
        /**
         * Max value for enum ClassTypes_MAX
         */
-       public static final int ClassTypes_MAX = 1040;
+       public static final int ClassTypes_MAX = 1048;
        
        /***************************************************************
         * Enum values for Default SortOrder

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/bc090a66/security-admin/src/main/java/org/apache/ranger/db/RangerDaoManagerBase.java
----------------------------------------------------------------------
diff --git 
a/security-admin/src/main/java/org/apache/ranger/db/RangerDaoManagerBase.java 
b/security-admin/src/main/java/org/apache/ranger/db/RangerDaoManagerBase.java
index da66044..da01853 100644
--- 
a/security-admin/src/main/java/org/apache/ranger/db/RangerDaoManagerBase.java
+++ 
b/security-admin/src/main/java/org/apache/ranger/db/RangerDaoManagerBase.java
@@ -29,6 +29,8 @@ import org.apache.log4j.Logger;
 import org.apache.ranger.common.AppConstants;
 import org.apache.ranger.common.RESTErrorUtil;
 import org.apache.ranger.common.db.BaseDao;
+import org.apache.ranger.entity.XXTagDef;
+import org.apache.ranger.entity.XXTaggedResource;
 import org.springframework.beans.factory.annotation.Autowired;
 
 
@@ -162,6 +164,31 @@ public abstract class RangerDaoManagerBase {
                        return getXXServiceDefWithAssignedId();
                }
                
+               if (classType == AppConstants.CLASS_TYPE_XA_TAG_DEF) {
+                       return getXXTagDef();
+               }
+               if (classType == AppConstants.CLASS_TYPE_XA_TAG_ATTR_DEF) {
+                       return getXXTagAttributeDef();
+               }
+               if (classType == AppConstants.CLASS_TYPE_XA_TAGGED_RESOURCE) {
+                       return getXXTaggedResource();
+               }
+               if (classType == 
AppConstants.CLASS_TYPE_XA_TAGGED_RESOURCE_VALUE) {
+                       return getXXTaggedResourceValue();
+               }
+               if (classType == 
AppConstants.CLASS_TYPE_XA_TAGGED_RESOURCE_VALUE_MAP) {
+                       return getXXTaggedResourceValueMap();
+               }
+               if (classType == AppConstants.CLASS_TYPE_XA_TAG) {
+                       return getXXTag();
+               }
+               if (classType == AppConstants.CLASS_TYPE_XA_TAG_ATTR) {
+                       return getXXTagAttribute();
+               }
+               if (classType == AppConstants.CLASS_TYPE_XA_TAG_RESOURCE_MAP) {
+                       return getXXTagResourceMap();
+               }
+               
                logger.error("No DaoManager found for classType=" + classType, 
new Throwable());
                return null;
        }
@@ -290,7 +317,32 @@ public abstract class RangerDaoManagerBase {
                if (className.equals("XXServiceDefWithAssignedId")) {
                        return getXXServiceDefWithAssignedId();
                }
-               
+
+               if (className.equals("XXTagDef")) {
+                       return getXXTagDef();
+               }
+               if (className.equals("XXTagAttributeDef")) {
+                       return getXXTagAttributeDef();
+               }
+               if (className.equals("XXTaggedResource")) {
+                       return getXXTaggedResource();
+               }
+               if (className.equals("XXTaggedResourceValue")) {
+                       return getXXTaggedResourceValue();
+               }
+               if (className.equals("XXTaggedResourceValueMap")) {
+                       return getXXTaggedResourceValueMap();
+               }
+               if (className.equals("XXTag")) {
+                       return getXXTag();
+               }
+               if (className.equals("XXTagAttribute")) {
+                       return getXXTagAttribute();
+               }
+               if (className.equals("XXTagResourceMap")) {
+                       return getXXTagResourceMap();
+               }
+
                logger.error("No DaoManager found for className=" + className, 
new Throwable());
                return null;
        }
@@ -466,5 +518,37 @@ public abstract class RangerDaoManagerBase {
                return new XXServiceDefWithAssignedIdDao(this);
        }
 
+       public XXTagDefDao getXXTagDef() {
+               return new XXTagDefDao(this);
+       }
+
+       public XXTagAttributeDefDao getXXTagAttributeDef() {
+               return new XXTagAttributeDefDao(this);
+       }
+
+       public XXTaggedResourceDao getXXTaggedResource() {
+               return new XXTaggedResourceDao(this);
+       }
+
+       public XXTaggedResourceValueDao getXXTaggedResourceValue() {
+               return new XXTaggedResourceValueDao(this);
+       }
+
+       public XXTaggedResourceValueMapDao getXXTaggedResourceValueMap() {
+               return new XXTaggedResourceValueMapDao(this);
+       }
+
+       public XXTagDao getXXTag() {
+               return new XXTagDao(this);
+       }
+
+       public XXTagAttributeDao getXXTagAttribute() {
+               return new XXTagAttributeDao(this);
+       }
+
+       public XXTagResourceMapDao getXXTagResourceMap() {
+               return new XXTagResourceMapDao(this);
+       }
+
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/bc090a66/security-admin/src/main/java/org/apache/ranger/db/XXTagAttributeDao.java
----------------------------------------------------------------------
diff --git 
a/security-admin/src/main/java/org/apache/ranger/db/XXTagAttributeDao.java 
b/security-admin/src/main/java/org/apache/ranger/db/XXTagAttributeDao.java
new file mode 100644
index 0000000..5ba3b74
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXTagAttributeDao.java
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+package org.apache.ranger.db;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.NoResultException;
+
+import org.apache.ranger.common.db.BaseDao;
+import org.apache.ranger.entity.XXTagAttribute;
+
+public class XXTagAttributeDao extends BaseDao<XXTagAttribute> {
+
+       public XXTagAttributeDao(RangerDaoManagerBase daoManager) {
+               super(daoManager);
+       }
+
+       public List<XXTagAttribute> findByTagId(Long tagId) {
+               if (tagId == null) {
+                       return new ArrayList<XXTagAttribute>();
+               }
+               try {
+                       return 
getEntityManager().createNamedQuery("XXTagAttribute.findByTagId", tClass)
+                                       .setParameter("tagId", 
tagId).getResultList();
+               } catch (NoResultException e) {
+                       return new ArrayList<XXTagAttribute>();
+               }
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/bc090a66/security-admin/src/main/java/org/apache/ranger/db/XXTagAttributeDefDao.java
----------------------------------------------------------------------
diff --git 
a/security-admin/src/main/java/org/apache/ranger/db/XXTagAttributeDefDao.java 
b/security-admin/src/main/java/org/apache/ranger/db/XXTagAttributeDefDao.java
new file mode 100644
index 0000000..c8cb91d
--- /dev/null
+++ 
b/security-admin/src/main/java/org/apache/ranger/db/XXTagAttributeDefDao.java
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+package org.apache.ranger.db;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.NoResultException;
+
+import org.apache.ranger.common.db.BaseDao;
+import org.apache.ranger.entity.XXTagAttributeDef;
+
+public class XXTagAttributeDefDao extends BaseDao<XXTagAttributeDef> {
+
+       public XXTagAttributeDefDao(RangerDaoManagerBase daoManager) {
+               super(daoManager);
+       }
+
+       public List<XXTagAttributeDef> findByTagDefId(Long tagDefId) {
+               if (tagDefId == null) {
+                       return new ArrayList<XXTagAttributeDef>();
+               }
+               try {
+                       return 
getEntityManager().createNamedQuery("XXTagAttributeDef.findByTagDefId", tClass)
+                                       .setParameter("tagDefId", 
tagDefId).getResultList();
+               } catch (NoResultException e) {
+                       return new ArrayList<XXTagAttributeDef>();
+               }
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/bc090a66/security-admin/src/main/java/org/apache/ranger/db/XXTagDao.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXTagDao.java 
b/security-admin/src/main/java/org/apache/ranger/db/XXTagDao.java
new file mode 100644
index 0000000..d8562d2
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXTagDao.java
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+
+package org.apache.ranger.db;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.NoResultException;
+
+import org.apache.ranger.common.db.BaseDao;
+import org.apache.ranger.entity.XXTag;
+
+public class XXTagDao extends BaseDao<XXTag> {
+
+       public XXTagDao(RangerDaoManagerBase daoManager) {
+               super(daoManager);
+       }
+
+       public List<XXTag> findByTaggedResource(Long taggedResId) {
+               if (taggedResId == null) {
+                       return new ArrayList<XXTag>();
+               }
+               try {
+                       return 
getEntityManager().createNamedQuery("XXTag.findByTaggedResource", tClass)
+                                       .setParameter("taggedResId", 
taggedResId).getResultList();
+               } catch (NoResultException e) {
+                       return new ArrayList<XXTag>();
+               }
+       }
+
+       @SuppressWarnings("unchecked")
+       public List<String> findTagNamesByServiceId(Long serviceId) {
+               if (serviceId == null) {
+                       return new ArrayList<String>();
+               }
+               try {
+                       return 
getEntityManager().createNamedQuery("XXTag.findTagNamesByServiceId")
+                                       .setParameter("serviceId", 
serviceId).getResultList();
+               } catch (NoResultException e) {
+                       return new ArrayList<String>();
+               }
+       }
+
+       public List<XXTag> findTagsByExternalId(String externalId) {
+               if (externalId == null) {
+                       return new ArrayList<XXTag>();
+               }
+               try {
+                       return 
getEntityManager().createNamedQuery("XXTag.findTagsByExternalId", tClass)
+                                       .setParameter("externalId", 
externalId).getResultList();
+               } catch (NoResultException e) {
+                       return new ArrayList<XXTag>();
+               }
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/bc090a66/security-admin/src/main/java/org/apache/ranger/db/XXTagDefDao.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXTagDefDao.java 
b/security-admin/src/main/java/org/apache/ranger/db/XXTagDefDao.java
new file mode 100644
index 0000000..f4c00da
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXTagDefDao.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+package org.apache.ranger.db;
+
+import org.apache.ranger.common.db.BaseDao;
+import org.apache.ranger.entity.XXTagDef;
+
+public class XXTagDefDao extends BaseDao<XXTagDef> {
+
+       public XXTagDefDao(RangerDaoManagerBase daoManager) {
+               super(daoManager);
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/bc090a66/security-admin/src/main/java/org/apache/ranger/db/XXTagResourceMapDao.java
----------------------------------------------------------------------
diff --git 
a/security-admin/src/main/java/org/apache/ranger/db/XXTagResourceMapDao.java 
b/security-admin/src/main/java/org/apache/ranger/db/XXTagResourceMapDao.java
new file mode 100644
index 0000000..57ac5e8
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXTagResourceMapDao.java
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+package org.apache.ranger.db;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.NoResultException;
+
+import org.apache.ranger.common.db.BaseDao;
+import org.apache.ranger.entity.XXTagResourceMap;
+
+public class XXTagResourceMapDao extends BaseDao<XXTagResourceMap> {
+
+       public XXTagResourceMapDao(RangerDaoManagerBase daoManager) {
+               super(daoManager);
+       }
+
+       public List<XXTagResourceMap> findByTaggedResourceId(Long taggedResId) {
+               if (taggedResId == null) {
+                       return new ArrayList<XXTagResourceMap>();
+               }
+               try {
+                       return 
getEntityManager().createNamedQuery("XXTagResourceMap.findByTaggedResourceId", 
tClass)
+                                       .setParameter("taggedResId", 
taggedResId).getResultList();
+               } catch (NoResultException e) {
+                       return new ArrayList<XXTagResourceMap>();
+               }
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/bc090a66/security-admin/src/main/java/org/apache/ranger/db/XXTaggedResourceDao.java
----------------------------------------------------------------------
diff --git 
a/security-admin/src/main/java/org/apache/ranger/db/XXTaggedResourceDao.java 
b/security-admin/src/main/java/org/apache/ranger/db/XXTaggedResourceDao.java
new file mode 100644
index 0000000..b7c2b3e
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXTaggedResourceDao.java
@@ -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.
+ */
+
+package org.apache.ranger.db;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.NoResultException;
+
+import org.apache.ranger.common.db.BaseDao;
+import org.apache.ranger.entity.XXTaggedResource;
+
+public class XXTaggedResourceDao extends BaseDao<XXTaggedResource> {
+
+       public XXTaggedResourceDao(RangerDaoManagerBase daoManager) {
+               super(daoManager);
+       }
+
+       public List<XXTaggedResource> findByServiceId(Long serviceId) {
+               if (serviceId == null) {
+                       return new ArrayList<XXTaggedResource>();
+               }
+               try {
+                       return 
getEntityManager().createNamedQuery("XXTaggedResource.findByServiceId", tClass)
+                                       .setParameter("serviceId", 
serviceId).getResultList();
+               } catch (NoResultException e) {
+                       return new ArrayList<XXTaggedResource>();
+               }
+
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/bc090a66/security-admin/src/main/java/org/apache/ranger/db/XXTaggedResourceValueDao.java
----------------------------------------------------------------------
diff --git 
a/security-admin/src/main/java/org/apache/ranger/db/XXTaggedResourceValueDao.java
 
b/security-admin/src/main/java/org/apache/ranger/db/XXTaggedResourceValueDao.java
new file mode 100644
index 0000000..6f72a3c
--- /dev/null
+++ 
b/security-admin/src/main/java/org/apache/ranger/db/XXTaggedResourceValueDao.java
@@ -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.
+ */
+
+package org.apache.ranger.db;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.NoResultException;
+
+import org.apache.ranger.common.db.BaseDao;
+import org.apache.ranger.entity.XXTaggedResourceValue;
+
+public class XXTaggedResourceValueDao extends BaseDao<XXTaggedResourceValue> {
+
+       public XXTaggedResourceValueDao(RangerDaoManagerBase daoManager) {
+               super(daoManager);
+       }
+
+       public List<XXTaggedResourceValue> findByTaggedResId(Long taggedResId) {
+               if (taggedResId == null) {
+                       return new ArrayList<XXTaggedResourceValue>();
+               }
+               try {
+                       return 
getEntityManager().createNamedQuery("XXTaggedResourceValue.findByTaggedResId", 
tClass)
+                                       .setParameter("taggedResId", 
taggedResId)
+                                       .getResultList();
+               } catch (NoResultException e) {
+                       return new ArrayList<XXTaggedResourceValue>();
+               }
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/bc090a66/security-admin/src/main/java/org/apache/ranger/db/XXTaggedResourceValueMapDao.java
----------------------------------------------------------------------
diff --git 
a/security-admin/src/main/java/org/apache/ranger/db/XXTaggedResourceValueMapDao.java
 
b/security-admin/src/main/java/org/apache/ranger/db/XXTaggedResourceValueMapDao.java
new file mode 100644
index 0000000..016766f
--- /dev/null
+++ 
b/security-admin/src/main/java/org/apache/ranger/db/XXTaggedResourceValueMapDao.java
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+
+package org.apache.ranger.db;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.NoResultException;
+
+import org.apache.ranger.common.db.BaseDao;
+import org.apache.ranger.entity.XXTaggedResourceValue;
+import org.apache.ranger.entity.XXTaggedResourceValueMap;
+
+public class XXTaggedResourceValueMapDao extends 
BaseDao<XXTaggedResourceValueMap> {
+
+       public XXTaggedResourceValueMapDao(RangerDaoManagerBase daoManager) {
+               super(daoManager);
+       }
+
+       public List<XXTaggedResourceValueMap> findByResValueId(Long resValueId) 
{
+               if (resValueId == null) {
+                       return new ArrayList<XXTaggedResourceValueMap>();
+               }
+               try {
+                       return 
getEntityManager().createNamedQuery("XXTaggedResourceValueMap.findByResValueId",
 tClass)
+                                       .setParameter("resValueId", 
resValueId).getResultList();
+               } catch (NoResultException e) {
+                       return new ArrayList<XXTaggedResourceValueMap>();
+               }
+       }
+       
+       @SuppressWarnings("unchecked")
+       public List<String> findValuesByResValueId(Long resValueId) {
+               if (resValueId == null) {
+                       return new ArrayList<String>();
+               }
+               try {
+                       return 
getEntityManager().createNamedQuery("XXTaggedResourceValueMap.findValuesByResValueId")
+                                       .setParameter("resValueId", 
resValueId).getResultList();
+               } catch (NoResultException e) {
+                       return new ArrayList<String>();
+               }
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/bc090a66/security-admin/src/main/java/org/apache/ranger/entity/XXTag.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXTag.java 
b/security-admin/src/main/java/org/apache/ranger/entity/XXTag.java
new file mode 100644
index 0000000..af15b0a
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXTag.java
@@ -0,0 +1,220 @@
+/*
+ * 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.
+ */
+
+package org.apache.ranger.entity;
+
+import java.io.Serializable;
+
+import javax.persistence.Cacheable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.ranger.common.AppConstants;
+
+@Entity
+@Cacheable
+@Table(name="x_tag")
+@XmlRootElement
+public class XXTag extends XXDBBase implements Serializable {
+       private static final long serialVersionUID = 1L;
+
+       @Id
+       @SequenceGenerator(name = "XXTagSEQ", sequenceName = "XXTagSEQ", 
allocationSize = 1)
+       @GeneratedValue(strategy = GenerationType.AUTO, generator = "XXTagSEQ")
+       @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;
+
+       @Column(name = "external_id")
+       protected String externalId;
+
+       @Column(name = "name")
+       protected String name;
+
+       @Override
+       public void setId(Long id) {
+               this.id = id;
+       }
+
+       @Override
+       public Long getId() {
+               return id;
+       }
+
+       /**
+        * @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() {
+               return tagDefId;
+       }
+
+       /**
+        * @param tagDefId
+        *            the tagDefId to set
+        */
+       public void setTagDefId(Long tagDefId) {
+               this.tagDefId = tagDefId;
+       }
+
+       /**
+        * @return the name
+        */
+       public String getName() {
+               return name;
+       }
+
+       /**
+        * @param name
+        *            the name to set
+        */
+       public void setName(String name) {
+               this.name = name;
+       }
+
+       /**
+        * @return the externalId
+        */
+       public String getExternalId() {
+               return externalId;
+       }
+
+       /**
+        * @param externalId
+        *            the externalId to set
+        */
+       public void setExternalId(String externalId) {
+               this.externalId = externalId;
+       }
+
+       @Override
+       public int getMyClassType() {
+               return AppConstants.CLASS_TYPE_XA_TAG;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see java.lang.Object#hashCode()
+        */
+       @Override
+       public int hashCode() {
+               final int prime = 31;
+               int result = 1;
+               result = prime * result + ((externalId == null) ? 0 : 
externalId.hashCode());
+               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());
+               return result;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see java.lang.Object#equals(java.lang.Object)
+        */
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj)
+                       return true;
+               if (!super.equals(obj))
+                       return false;
+               if (getClass() != obj.getClass())
+                       return false;
+               XXTag other = (XXTag) obj;
+               if (externalId == null) {
+                       if (other.externalId != null)
+                               return false;
+               } else if (!externalId.equals(other.externalId))
+                       return false;
+               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;
+               } else if (!id.equals(other.id))
+                       return false;
+               if (name == null) {
+                       if (other.name != null)
+                               return false;
+               } else if (!name.equals(other.name))
+                       return false;
+               if (tagDefId == null) {
+                       if (other.tagDefId != null)
+                               return false;
+               } else if (!tagDefId.equals(other.tagDefId))
+                       return false;
+               return true;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see java.lang.Object#toString()
+        */
+       @Override
+       public String toString() {
+               StringBuilder sb = new StringBuilder();
+               toString(sb);
+               return sb.toString();
+       }
+
+       public StringBuilder toString(StringBuilder sb) {
+               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("externalId={").append(externalId).append("} ");
+               sb.append("name={").append(name).append("} ");
+               sb.append(" }");
+
+               return sb;
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/bc090a66/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
new file mode 100644
index 0000000..3bb2207
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXTagAttribute.java
@@ -0,0 +1,220 @@
+/*
+ * 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.
+ */
+
+package org.apache.ranger.entity;
+
+import java.io.Serializable;
+
+import javax.persistence.Cacheable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.ranger.common.AppConstants;
+
+@Entity
+@Cacheable
+@Table(name="x_tag_attr")
+@XmlRootElement
+public class XXTagAttribute extends XXDBBase implements Serializable {
+       private static final long serialVersionUID = 1L;
+
+       @Id
+       @SequenceGenerator(name = "XXTagAttributeSEQ", sequenceName = 
"XXTagAttributeSEQ", allocationSize = 1)
+       @GeneratedValue(strategy = GenerationType.AUTO, generator = 
"XXTagAttributeSEQ")
+       @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")
+       protected String name;
+
+       @Column(name = "attr_value")
+       protected String value;
+
+       @Override
+       public void setId(Long id) {
+               this.id = id;
+       }
+
+       @Override
+       public Long getId() {
+               return id;
+       }
+
+       /**
+        * @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() {
+               return tagId;
+       }
+
+       /**
+        * @param tagId
+        *            the tagId to set
+        */
+       public void setTagId(Long tagId) {
+               this.tagId = tagId;
+       }
+
+       /**
+        * @return the name
+        */
+       public String getName() {
+               return name;
+       }
+
+       /**
+        * @param name
+        *            the name to set
+        */
+       public void setName(String name) {
+               this.name = name;
+       }
+
+       /**
+        * @return the value
+        */
+       public String getValue() {
+               return value;
+       }
+
+       /**
+        * @param value
+        *            the value to set
+        */
+       public void setValue(String value) {
+               this.value = value;
+       }
+
+       @Override
+       public int getMyClassType() {
+               return AppConstants.CLASS_TYPE_XA_TAG_ATTR;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see java.lang.Object#hashCode()
+        */
+       @Override
+       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());
+               result = prime * result + ((value == null) ? 0 : 
value.hashCode());
+               return result;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see java.lang.Object#equals(java.lang.Object)
+        */
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj)
+                       return true;
+               if (!super.equals(obj))
+                       return false;
+               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;
+               } else if (!id.equals(other.id))
+                       return false;
+               if (name == null) {
+                       if (other.name != null)
+                               return false;
+               } else if (!name.equals(other.name))
+                       return false;
+               if (tagId == null) {
+                       if (other.tagId != null)
+                               return false;
+               } else if (!tagId.equals(other.tagId))
+                       return false;
+               if (value == null) {
+                       if (other.value != null)
+                               return false;
+               } else if (!value.equals(other.value))
+                       return false;
+               return true;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see java.lang.Object#toString()
+        */
+       @Override
+       public String toString() {
+               StringBuilder sb = new StringBuilder();
+               toString(sb);
+               return sb.toString();
+       }
+
+       public StringBuilder toString(StringBuilder sb) {
+               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("} ");
+               sb.append(" }");
+
+               return sb;
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/bc090a66/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
new file mode 100644
index 0000000..4653481
--- /dev/null
+++ 
b/security-admin/src/main/java/org/apache/ranger/entity/XXTagAttributeDef.java
@@ -0,0 +1,220 @@
+/*
+ * 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.
+ */
+
+package org.apache.ranger.entity;
+
+import java.io.Serializable;
+
+import javax.persistence.Cacheable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.ranger.common.AppConstants;
+
+@Entity
+@Cacheable
+@XmlRootElement
+@Table(name = "x_tag_attr_def")
+public class XXTagAttributeDef extends XXDBBase implements Serializable {
+       private static final long serialVersionUID = 1L;
+
+       @Id
+       @SequenceGenerator(name = "XXTagAttributeDefSEQ", sequenceName = 
"XXTagAttributeDefSEQ", allocationSize = 1)
+       @GeneratedValue(strategy = GenerationType.AUTO, generator = 
"XXTagAttributeDefSEQ")
+       @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;
+
+       @Column(name = "name")
+       protected String name;
+
+       @Column(name = "type")
+       protected String type;
+
+       @Override
+       public void setId(Long id) {
+               this.id = id;
+       }
+
+       @Override
+       public Long getId() {
+               return id;
+       }
+
+       /**
+        * @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() {
+               return tagDefId;
+       }
+
+       /**
+        * @param tagDefId
+        *            the tagDefId to set
+        */
+       public void setTagDefId(Long tagDefId) {
+               this.tagDefId = tagDefId;
+       }
+
+       /**
+        * @return the name
+        */
+       public String getName() {
+               return name;
+       }
+
+       /**
+        * @param name
+        *            the name to set
+        */
+       public void setName(String name) {
+               this.name = name;
+       }
+
+       /**
+        * @return the type
+        */
+       public String getType() {
+               return type;
+       }
+
+       /**
+        * @param type
+        *            the type to set
+        */
+       public void setType(String type) {
+               this.type = type;
+       }
+
+       @Override
+       public int getMyClassType() {
+               return AppConstants.CLASS_TYPE_XA_TAG_ATTR_DEF;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see java.lang.Object#hashCode()
+        */
+       @Override
+       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());
+               result = prime * result + ((type == null) ? 0 : 
type.hashCode());
+               return result;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see java.lang.Object#equals(java.lang.Object)
+        */
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj)
+                       return true;
+               if (!super.equals(obj))
+                       return false;
+               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;
+               } else if (!id.equals(other.id))
+                       return false;
+               if (name == null) {
+                       if (other.name != null)
+                               return false;
+               } else if (!name.equals(other.name))
+                       return false;
+               if (tagDefId == null) {
+                       if (other.tagDefId != null)
+                               return false;
+               } else if (!tagDefId.equals(other.tagDefId))
+                       return false;
+               if (type == null) {
+                       if (other.type != null)
+                               return false;
+               } else if (!type.equals(other.type))
+                       return false;
+               return true;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see java.lang.Object#toString()
+        */
+       @Override
+       public String toString() {
+               StringBuilder sb = new StringBuilder();
+               toString(sb);
+               return sb.toString();
+       }
+
+       public StringBuilder toString(StringBuilder sb) {
+               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("} ");
+               sb.append(" }");
+
+               return sb;
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/bc090a66/security-admin/src/main/java/org/apache/ranger/entity/XXTagDef.java
----------------------------------------------------------------------
diff --git 
a/security-admin/src/main/java/org/apache/ranger/entity/XXTagDef.java 
b/security-admin/src/main/java/org/apache/ranger/entity/XXTagDef.java
new file mode 100644
index 0000000..256522a
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXTagDef.java
@@ -0,0 +1,245 @@
+/*
+ * 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.
+ */
+
+package org.apache.ranger.entity;
+
+import java.io.Serializable;
+
+import javax.persistence.Cacheable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.ranger.common.AppConstants;
+
+@Entity
+@Cacheable
+@XmlRootElement
+@Table(name = "x_tag_def")
+public class XXTagDef extends XXDBBase implements Serializable {
+       private static final long serialVersionUID = 1L;
+
+       @Id
+       @SequenceGenerator(name = "XXTagDefSEQ", sequenceName = "XXTagDefSEQ", 
allocationSize = 1)
+       @GeneratedValue(strategy = GenerationType.AUTO, generator = 
"XXTagDefSEQ")
+       @Column(name = "id")
+       protected Long id;
+
+       @Column(name = "guid", unique = true, nullable = false, length = 512)
+       protected String guid;
+
+       @Column(name = "version")
+       protected Long version;
+
+       @Column(name = "is_enabled")
+       protected Boolean isEnabled;
+
+       @Column(name = "name")
+       protected String name;
+
+       @Column(name = "source")
+       protected String source;
+
+       /**
+        * @return the guid
+        */
+       public String getGuid() {
+               return guid;
+       }
+
+       /**
+        * @param guid
+        *            the guid to set
+        */
+       public void setGuid(String guid) {
+               this.guid = guid;
+       }
+
+       /**
+        * @return the version
+        */
+       public Long getVersion() {
+               return version;
+       }
+
+       /**
+        * @param version
+        *            the version to set
+        */
+       public void setVersion(Long version) {
+               this.version = version;
+       }
+
+       /**
+        * @return the isEnabled
+        */
+       public Boolean getIsEnabled() {
+               return isEnabled;
+       }
+
+       /**
+        * @param isEnabled
+        *            the isEnabled to set
+        */
+       public void setIsEnabled(Boolean isEnabled) {
+               this.isEnabled = isEnabled;
+       }
+
+       /**
+        * @return the name
+        */
+       public String getName() {
+               return name;
+       }
+
+       /**
+        * @param name
+        *            the name to set
+        */
+       public void setName(String name) {
+               this.name = name;
+       }
+
+       /**
+        * @return the source
+        */
+       public String getSource() {
+               return source;
+       }
+
+       /**
+        * @param source
+        *            the source to set
+        */
+       public void setSource(String source) {
+               this.source = source;
+       }
+
+       @Override
+       public void setId(Long id) {
+               this.id = id;
+       }
+
+       @Override
+       public Long getId() {
+               return id;
+       }
+
+       @Override
+       public int getMyClassType() {
+               return AppConstants.CLASS_TYPE_XA_TAG_DEF;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see java.lang.Object#hashCode()
+        */
+       @Override
+       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 + ((isEnabled == null) ? 0 : 
isEnabled.hashCode());
+               result = prime * result + ((name == null) ? 0 : 
name.hashCode());
+               result = prime * result + ((source == null) ? 0 : 
source.hashCode());
+               result = prime * result + ((version == null) ? 0 : 
version.hashCode());
+               return result;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see java.lang.Object#equals(java.lang.Object)
+        */
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj)
+                       return true;
+               if (!super.equals(obj))
+                       return false;
+               if (getClass() != obj.getClass())
+                       return false;
+               XXTagDef other = (XXTagDef) 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;
+               } else if (!id.equals(other.id))
+                       return false;
+               if (isEnabled == null) {
+                       if (other.isEnabled != null)
+                               return false;
+               } else if (!isEnabled.equals(other.isEnabled))
+                       return false;
+               if (name == null) {
+                       if (other.name != null)
+                               return false;
+               } else if (!name.equals(other.name))
+                       return false;
+               if (source == null) {
+                       if (other.source != null)
+                               return false;
+               } else if (!source.equals(other.source))
+                       return false;
+               if (version == null) {
+                       if (other.version != null)
+                               return false;
+               } else if (!version.equals(other.version))
+                       return false;
+               return true;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see java.lang.Object#toString()
+        */
+       @Override
+       public String toString() {
+               StringBuilder sb = new StringBuilder();
+               toString(sb);
+               return sb.toString();
+       }
+
+       public StringBuilder toString(StringBuilder sb) {
+               sb.append("{ ");
+               sb.append(super.toString() + "} ");
+               sb.append("id={").append(id).append("} ");
+               sb.append("guid={").append(guid).append("} ");
+               sb.append("version={").append(version).append("} ");
+               sb.append("isEnabled={").append(isEnabled).append("} ");
+               sb.append("source={").append(source).append("} ");
+               sb.append("name={").append(name).append("} ");
+               sb.append(" }");
+
+               return sb;
+       }
+
+}

Reply via email to