You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by ma...@apache.org on 2015/06/03 22:44:00 UTC
incubator-ranger git commit: RANGER-527 : System should preserve
Service-def ID if its given at the time of creating
Repository: incubator-ranger
Updated Branches:
refs/heads/master 866c01aae -> de019a805
RANGER-527 : System should preserve Service-def ID if its given at the time of creating
Signed-off-by: Madhan Neethiraj <ma...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/de019a80
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/de019a80
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/de019a80
Branch: refs/heads/master
Commit: de019a805622b5013a68949a1167dd67c2d90cbe
Parents: 866c01a
Author: Gautam Borad <gb...@gmail.com>
Authored: Wed Jun 3 22:38:56 2015 +0530
Committer: Madhan Neethiraj <ma...@apache.org>
Committed: Wed Jun 3 13:36:47 2015 -0700
----------------------------------------------------------------------
.../plugin/store/EmbeddedServiceDefsUtil.java | 8 +-
.../ranger/plugin/store/ServiceStore.java | 4 +
.../plugin/store/file/ServiceFileStore.java | 11 +
.../plugin/store/rest/ServiceRESTStore.java | 12 +
.../service-defs/ranger-servicedef-hbase.json | 1 +
.../service-defs/ranger-servicedef-hdfs.json | 1 +
.../service-defs/ranger-servicedef-hive.json | 1 +
.../service-defs/ranger-servicedef-kafka.json | 1 +
.../service-defs/ranger-servicedef-kms.json | 1 +
.../service-defs/ranger-servicedef-knox.json | 1 +
.../service-defs/ranger-servicedef-solr.json | 1 +
.../service-defs/ranger-servicedef-storm.json | 1 +
.../service-defs/ranger-servicedef-yarn.json | 1 +
.../org/apache/ranger/biz/ServiceDBStore.java | 22 +-
.../org/apache/ranger/common/AppConstants.java | 8 +-
.../apache/ranger/db/RangerDaoManagerBase.java | 10 +
.../db/XXServiceDefWithAssignedIdDao.java | 29 ++
.../org/apache/ranger/entity/XXServiceDef.java | 364 +-----------------
.../apache/ranger/entity/XXServiceDefBase.java | 375 +++++++++++++++++++
.../entity/XXServiceDefWithAssignedId.java | 76 ++++
.../ranger/service/RangerServiceDefService.java | 153 +-------
.../service/RangerServiceDefServiceBase.java | 129 ++++++-
.../RangerServiceDefWithAssignedIdService.java | 58 +++
23 files changed, 760 insertions(+), 508 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/de019a80/agents-common/src/main/java/org/apache/ranger/plugin/store/EmbeddedServiceDefsUtil.java
----------------------------------------------------------------------
diff --git a/agents-common/src/main/java/org/apache/ranger/plugin/store/EmbeddedServiceDefsUtil.java b/agents-common/src/main/java/org/apache/ranger/plugin/store/EmbeddedServiceDefsUtil.java
index 77e2c80..8513230 100755
--- a/agents-common/src/main/java/org/apache/ranger/plugin/store/EmbeddedServiceDefsUtil.java
+++ b/agents-common/src/main/java/org/apache/ranger/plugin/store/EmbeddedServiceDefsUtil.java
@@ -169,7 +169,13 @@ public class EmbeddedServiceDefsUtil {
ret = loadEmbeddedServiceDef(serviceDefName);
LOG.info("creating embedded service-def " + serviceDefName);
- ret = store.createServiceDef(ret);
+ if (ret.getId() != null) {
+ store.setPopulateExistingBaseFields(true);
+ store.createServiceDef(ret);
+ store.setPopulateExistingBaseFields(false);
+ } else {
+ store.createServiceDef(ret);
+ }
}
} catch(Exception excp) {
LOG.fatal("EmbeddedServiceDefsUtil.getOrCreateServiceDef(): failed to load/create serviceType " + serviceDefName, excp);
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/de019a80/agents-common/src/main/java/org/apache/ranger/plugin/store/ServiceStore.java
----------------------------------------------------------------------
diff --git a/agents-common/src/main/java/org/apache/ranger/plugin/store/ServiceStore.java b/agents-common/src/main/java/org/apache/ranger/plugin/store/ServiceStore.java
index b998e93..7957dbf 100644
--- a/agents-common/src/main/java/org/apache/ranger/plugin/store/ServiceStore.java
+++ b/agents-common/src/main/java/org/apache/ranger/plugin/store/ServiceStore.java
@@ -73,4 +73,8 @@ public interface ServiceStore {
List<RangerPolicy> getServicePolicies(String serviceName, SearchFilter filter) throws Exception;
ServicePolicies getServicePoliciesIfUpdated(String serviceName, Long lastKnownVersion) throws Exception;
+
+ void setPopulateExistingBaseFields(Boolean populateExistingBaseFields);
+
+ Boolean getPopulateExistingBaseFields();
}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/de019a80/agents-common/src/main/java/org/apache/ranger/plugin/store/file/ServiceFileStore.java
----------------------------------------------------------------------
diff --git a/agents-common/src/main/java/org/apache/ranger/plugin/store/file/ServiceFileStore.java b/agents-common/src/main/java/org/apache/ranger/plugin/store/file/ServiceFileStore.java
index 2e469cd..751c3b3 100644
--- a/agents-common/src/main/java/org/apache/ranger/plugin/store/file/ServiceFileStore.java
+++ b/agents-common/src/main/java/org/apache/ranger/plugin/store/file/ServiceFileStore.java
@@ -54,6 +54,7 @@ public class ServiceFileStore extends BaseFileStore implements ServiceStore {
private long nextPolicyId = 0;
private ServicePredicateUtil predicateUtil = null;
+ private Boolean populateExistingBaseFields = false;
public ServiceFileStore() {
if(LOG.isDebugEnabled()) {
@@ -943,4 +944,14 @@ public class ServiceFileStore extends BaseFileStore implements ServiceStore {
return ret;
}
+
+ @Override
+ public void setPopulateExistingBaseFields(Boolean populateExistingBaseFields) {
+ this.populateExistingBaseFields = populateExistingBaseFields;
+ }
+
+ @Override
+ public Boolean getPopulateExistingBaseFields() {
+ return populateExistingBaseFields;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/de019a80/agents-common/src/main/java/org/apache/ranger/plugin/store/rest/ServiceRESTStore.java
----------------------------------------------------------------------
diff --git a/agents-common/src/main/java/org/apache/ranger/plugin/store/rest/ServiceRESTStore.java b/agents-common/src/main/java/org/apache/ranger/plugin/store/rest/ServiceRESTStore.java
index 71405cf..6c4804d 100644
--- a/agents-common/src/main/java/org/apache/ranger/plugin/store/rest/ServiceRESTStore.java
+++ b/agents-common/src/main/java/org/apache/ranger/plugin/store/rest/ServiceRESTStore.java
@@ -69,6 +69,8 @@ public class ServiceRESTStore implements ServiceStore {
public final String REST_URL_POLICY_GET_FOR_SERVICE_IF_UPDATED = "/service/plugins/policies/download/";
public static final String REST_MIME_TYPE_JSON = "application/json" ;
+
+ private Boolean populateExistingBaseFields = false;
private RangerRESTClient restClient;
@@ -617,4 +619,14 @@ public class ServiceRESTStore implements ServiceStore {
public List<RangerPolicy> getPoliciesByResourceSignature(String serviceName, String policySignature, Boolean isPolicyEnabled) throws Exception {
throw new UnsupportedOperationException("Querying policies by resource signature is not supported!");
}
+
+ @Override
+ public void setPopulateExistingBaseFields(Boolean populateExistingBaseFields) {
+ this.populateExistingBaseFields = populateExistingBaseFields;
+ }
+
+ @Override
+ public Boolean getPopulateExistingBaseFields() {
+ return populateExistingBaseFields;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/de019a80/agents-common/src/main/resources/service-defs/ranger-servicedef-hbase.json
----------------------------------------------------------------------
diff --git a/agents-common/src/main/resources/service-defs/ranger-servicedef-hbase.json b/agents-common/src/main/resources/service-defs/ranger-servicedef-hbase.json
index 61ff0f3..1f5f35b 100644
--- a/agents-common/src/main/resources/service-defs/ranger-servicedef-hbase.json
+++ b/agents-common/src/main/resources/service-defs/ranger-servicedef-hbase.json
@@ -1,4 +1,5 @@
{
+ "id":2,
"name": "hbase",
"implClass": "org.apache.ranger.services.hbase.RangerServiceHBase",
"label": "HBase",
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/de019a80/agents-common/src/main/resources/service-defs/ranger-servicedef-hdfs.json
----------------------------------------------------------------------
diff --git a/agents-common/src/main/resources/service-defs/ranger-servicedef-hdfs.json b/agents-common/src/main/resources/service-defs/ranger-servicedef-hdfs.json
index 37c020b..519d6a8 100755
--- a/agents-common/src/main/resources/service-defs/ranger-servicedef-hdfs.json
+++ b/agents-common/src/main/resources/service-defs/ranger-servicedef-hdfs.json
@@ -1,4 +1,5 @@
{
+ "id":1,
"name": "hdfs",
"implClass": "org.apache.ranger.services.hdfs.RangerServiceHdfs",
"label": "HDFS Repository",
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/de019a80/agents-common/src/main/resources/service-defs/ranger-servicedef-hive.json
----------------------------------------------------------------------
diff --git a/agents-common/src/main/resources/service-defs/ranger-servicedef-hive.json b/agents-common/src/main/resources/service-defs/ranger-servicedef-hive.json
index cda0efe..b01a1d8 100644
--- a/agents-common/src/main/resources/service-defs/ranger-servicedef-hive.json
+++ b/agents-common/src/main/resources/service-defs/ranger-servicedef-hive.json
@@ -1,4 +1,5 @@
{
+ "id":3,
"name": "hive",
"implClass": "org.apache.ranger.services.hive.RangerServiceHive",
"label": "Hive Server2",
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/de019a80/agents-common/src/main/resources/service-defs/ranger-servicedef-kafka.json
----------------------------------------------------------------------
diff --git a/agents-common/src/main/resources/service-defs/ranger-servicedef-kafka.json b/agents-common/src/main/resources/service-defs/ranger-servicedef-kafka.json
index 2d4142d..4752eff 100644
--- a/agents-common/src/main/resources/service-defs/ranger-servicedef-kafka.json
+++ b/agents-common/src/main/resources/service-defs/ranger-servicedef-kafka.json
@@ -1,4 +1,5 @@
{
+ "id":9,
"name":"kafka",
"implClass":"org.apache.ranger.services.kafka.RangerServiceKafka",
"label":"Kafka",
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/de019a80/agents-common/src/main/resources/service-defs/ranger-servicedef-kms.json
----------------------------------------------------------------------
diff --git a/agents-common/src/main/resources/service-defs/ranger-servicedef-kms.json b/agents-common/src/main/resources/service-defs/ranger-servicedef-kms.json
index 35d36e5..22a9cf2 100755
--- a/agents-common/src/main/resources/service-defs/ranger-servicedef-kms.json
+++ b/agents-common/src/main/resources/service-defs/ranger-servicedef-kms.json
@@ -1,4 +1,5 @@
{
+ "id":7,
"name": "kms",
"implClass": "org.apache.ranger.services.kms.RangerServiceKMS",
"label": "KMS",
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/de019a80/agents-common/src/main/resources/service-defs/ranger-servicedef-knox.json
----------------------------------------------------------------------
diff --git a/agents-common/src/main/resources/service-defs/ranger-servicedef-knox.json b/agents-common/src/main/resources/service-defs/ranger-servicedef-knox.json
index 33c09d2..495a699 100644
--- a/agents-common/src/main/resources/service-defs/ranger-servicedef-knox.json
+++ b/agents-common/src/main/resources/service-defs/ranger-servicedef-knox.json
@@ -1,4 +1,5 @@
{
+ "id":5,
"name": "knox",
"implClass": "org.apache.ranger.services.knox.RangerServiceKnox",
"label": "Knox Gateway",
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/de019a80/agents-common/src/main/resources/service-defs/ranger-servicedef-solr.json
----------------------------------------------------------------------
diff --git a/agents-common/src/main/resources/service-defs/ranger-servicedef-solr.json b/agents-common/src/main/resources/service-defs/ranger-servicedef-solr.json
index 2b492ae..107b5d6 100644
--- a/agents-common/src/main/resources/service-defs/ranger-servicedef-solr.json
+++ b/agents-common/src/main/resources/service-defs/ranger-servicedef-solr.json
@@ -1,4 +1,5 @@
{
+ "id":8,
"name":"solr",
"implClass":"org.apache.ranger.services.solr.RangerServiceSolr",
"label":"SOLR",
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/de019a80/agents-common/src/main/resources/service-defs/ranger-servicedef-storm.json
----------------------------------------------------------------------
diff --git a/agents-common/src/main/resources/service-defs/ranger-servicedef-storm.json b/agents-common/src/main/resources/service-defs/ranger-servicedef-storm.json
index 39ffc37..ab2780e 100644
--- a/agents-common/src/main/resources/service-defs/ranger-servicedef-storm.json
+++ b/agents-common/src/main/resources/service-defs/ranger-servicedef-storm.json
@@ -1,4 +1,5 @@
{
+ "id":6,
"name": "storm",
"implClass": "org.apache.ranger.services.storm.RangerServiceStorm",
"label": "Storm",
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/de019a80/agents-common/src/main/resources/service-defs/ranger-servicedef-yarn.json
----------------------------------------------------------------------
diff --git a/agents-common/src/main/resources/service-defs/ranger-servicedef-yarn.json b/agents-common/src/main/resources/service-defs/ranger-servicedef-yarn.json
index 21f5405..ff1f39f 100644
--- a/agents-common/src/main/resources/service-defs/ranger-servicedef-yarn.json
+++ b/agents-common/src/main/resources/service-defs/ranger-servicedef-yarn.json
@@ -1,4 +1,5 @@
{
+ "id":4,
"name": "yarn",
"implClass": "org.apache.ranger.services.yarn.RangerServiceYarn",
"label": "YARN",
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/de019a80/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java b/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java
index e0dbea29..b274387 100644
--- a/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java
+++ b/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java
@@ -110,6 +110,7 @@ import org.apache.ranger.service.RangerDataHistService;
import org.apache.ranger.service.RangerPolicyService;
import org.apache.ranger.service.RangerPolicyWithAssignedIdService;
import org.apache.ranger.service.RangerServiceDefService;
+import org.apache.ranger.service.RangerServiceDefWithAssignedIdService;
import org.apache.ranger.service.RangerServiceService;
import org.apache.ranger.service.RangerServiceWithAssignedIdService;
import org.apache.ranger.service.XUserService;
@@ -173,6 +174,9 @@ public class ServiceDBStore implements ServiceStore {
@Autowired
RangerServiceWithAssignedIdService svcServiceWithAssignedId;
+
+ @Autowired
+ RangerServiceDefWithAssignedIdService svcDefServiceWithAssignedId;
@Autowired
RangerFactory factory;
@@ -251,15 +255,21 @@ public class ServiceDBStore implements ServiceStore {
List<RangerContextEnricherDef> contextEnrichers = serviceDef.getContextEnrichers();
List<RangerEnumDef> enums = serviceDef.getEnums();
- // following fields will be auto populated
- serviceDef.setId(null);
- serviceDef.setCreateTime(null);
- serviceDef.setUpdateTime(null);
// While creating, value of version should be 1.
serviceDef.setVersion(new Long(1));
- serviceDef = serviceDefService.create(serviceDef);
+ if (populateExistingBaseFields) {
+ svcDefServiceWithAssignedId.setPopulateExistingBaseFields(true);
+ svcDefServiceWithAssignedId.create(serviceDef);
+ svcDefServiceWithAssignedId.setPopulateExistingBaseFields(false);
+ } else {
+ // following fields will be auto populated
+ serviceDef.setId(null);
+ serviceDef.setCreateTime(null);
+ serviceDef.setUpdateTime(null);
+ serviceDef = serviceDefService.create(serviceDef);
+ }
Long serviceDefId = serviceDef.getId();
XXServiceDef createdSvcDef = daoMgr.getXXServiceDef().getById(serviceDefId);
@@ -1970,10 +1980,12 @@ public class ServiceDBStore implements ServiceStore {
return true;
}
+ @Override
public Boolean getPopulateExistingBaseFields() {
return populateExistingBaseFields;
}
+ @Override
public void setPopulateExistingBaseFields(Boolean populateExistingBaseFields) {
this.populateExistingBaseFields = populateExistingBaseFields;
}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/de019a80/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 d58f221..59ab3db 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
@@ -521,7 +521,7 @@ public class AppConstants extends RangerCommonEnums {
/**
* CLASS_TYPE_XA_KMS_KEY is an element of enum ClassTypes. Its value is "CLASS_TYPE_XA_KMS_KEY".
*/
- public static final int CLASS_TYPE_XA_KMS_KEY = 1037;
+ public static final int CLASS_TYPE_XA_KMS_KEY = 1037;
/**
* CLASS_TYPE_RANGER_POLICY_WITH_ASSIGNED_ID is an element of enum ClassTypes. Its value is "CLASS_TYPE_RANGER_POLICY_WITH_ASSIGNED_ID".
*/
@@ -530,11 +530,15 @@ public class AppConstants extends RangerCommonEnums {
* CLASS_TYPE_RANGER_SERVICE_WITH_ASSIGNED_ID is an element of enum ClassTypes. Its value is "CLASS_TYPE_RANGER_SERVICE_WITH_ASSIGNED_ID".
*/
public static final int CLASS_TYPE_RANGER_SERVICE_WITH_ASSIGNED_ID = 1039;
+ /**
+ * 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;
/**
* Max value for enum ClassTypes_MAX
*/
- public static final int ClassTypes_MAX = 1039;
+ public static final int ClassTypes_MAX = 1040;
/***************************************************************
* Enum values for Default SortOrder
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/de019a80/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 06bb6db..da66044 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
@@ -158,6 +158,9 @@ public abstract class RangerDaoManagerBase {
if (classType == AppConstants.CLASS_TYPE_RANGER_GROUP_PERMISSION) {
return getXXUserPermission();
}
+ if (classType == AppConstants.CLASS_TYPE_RANGER_SERVICE_DEF_WITH_ASSIGNED_ID) {
+ return getXXServiceDefWithAssignedId();
+ }
logger.error("No DaoManager found for classType=" + classType, new Throwable());
return null;
@@ -284,6 +287,9 @@ public abstract class RangerDaoManagerBase {
if (className.equals("XXGroupPermission")) {
return getXXGroupPermission();
}
+ if (className.equals("XXServiceDefWithAssignedId")) {
+ return getXXServiceDefWithAssignedId();
+ }
logger.error("No DaoManager found for className=" + className, new Throwable());
return null;
@@ -455,6 +461,10 @@ public abstract class RangerDaoManagerBase {
public XXGroupPermissionDao getXXGroupPermission(){
return new XXGroupPermissionDao(this);
}
+
+ public XXServiceDefWithAssignedIdDao getXXServiceDefWithAssignedId() {
+ return new XXServiceDefWithAssignedIdDao(this);
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/de019a80/security-admin/src/main/java/org/apache/ranger/db/XXServiceDefWithAssignedIdDao.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXServiceDefWithAssignedIdDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXServiceDefWithAssignedIdDao.java
new file mode 100644
index 0000000..7e866d2
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXServiceDefWithAssignedIdDao.java
@@ -0,0 +1,29 @@
+/*
+ * 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.XXServiceDefWithAssignedId;
+
+public class XXServiceDefWithAssignedIdDao extends BaseDao<XXServiceDefWithAssignedId> {
+
+ public XXServiceDefWithAssignedIdDao(RangerDaoManagerBase daoManager) {
+ super(daoManager);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/de019a80/security-admin/src/main/java/org/apache/ranger/entity/XXServiceDef.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXServiceDef.java b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceDef.java
index 4e52eb9..af495e5 100644
--- a/security-admin/src/main/java/org/apache/ranger/entity/XXServiceDef.java
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceDef.java
@@ -25,8 +25,9 @@ import javax.xml.bind.annotation.XmlRootElement;
@Cacheable
@XmlRootElement
@Table(name = "x_service_def")
-public class XXServiceDef extends XXDBBase implements java.io.Serializable {
+public class XXServiceDef extends XXServiceDefBase implements java.io.Serializable {
private static final long serialVersionUID = 1L;
+
/**
* id of the XXServiceDef
* <ul>
@@ -40,92 +41,12 @@ public class XXServiceDef extends XXDBBase implements java.io.Serializable {
protected Long id;
/**
- * Global Id for the object
- * <ul>
- * <li>The maximum length for this attribute is <b>512</b>.
- * </ul>
- *
- */
- @Column(name = "guid", unique = true, nullable = false, length = 512)
- protected String guid;
- /**
- * version of the XXServiceDef
- * <ul>
- * </ul>
- *
- */
- @Column(name = "version")
- protected Long version;
-
- /**
- * name of the XXServiceDef
- * <ul>
- * </ul>
- *
- */
- @Column(name = "name")
- protected String name;
-
- /**
- * implClassName of the XXServiceDef
- * <ul>
- * </ul>
- *
- */
- @Column(name = "impl_class_name")
- protected String implClassName;
-
- /**
- * label of the XXServiceDef
- * <ul>
- * </ul>
- *
- */
- @Column(name = "label")
- protected String label;
-
- /**
- * description of the XXServiceDef
- * <ul>
- * </ul>
- *
- */
- @Column(name = "description")
- protected String description;
-
- /**
- * rbKeyLabel of the XXServiceDef
- * <ul>
- * </ul>
- *
- */
- @Column(name = "rb_key_label")
- protected String rbKeyLabel;
-
- /**
- * rbKeyDescription of the XXServiceDef
- * <ul>
- * </ul>
- *
- */
- @Column(name = "rb_key_description")
- protected String rbKeyDescription;
- /**
- * isEnabled of the XXPolicy
- * <ul>
- * </ul>
- *
- */
- @Column(name = "is_enabled")
- protected Boolean isEnabled;
-
- /**
- * This method sets the value to the member attribute <b> id</b> . You
- * cannot set null to the attribute.
+ * This method sets the value to the member attribute <b> id</b> . You cannot set null to the attribute.
*
* @param id
* Value to set member attribute <b> id</b>
*/
+ @Override
public void setId(Long id) {
this.id = id;
}
@@ -135,288 +56,31 @@ public class XXServiceDef extends XXDBBase implements java.io.Serializable {
*
* @return Date - value of member attribute <b>id</b> .
*/
+ @Override
public Long getId() {
return this.id;
}
- /**
- * @return the gUID
- */
- public String getGuid() {
- return this.guid;
- }
-
- /**
- * @param guid
- * the gUID to set
- */
- public void setGuid(String guid) {
- this.guid = guid;
- }
-
- /**
- * This method sets the value to the member attribute <b> version</b> . You
- * cannot set null to the attribute.
- *
- * @param version
- * Value to set member attribute <b> version</b>
- */
- public void setVersion(Long version) {
- this.version = version;
- }
-
- /**
- * Returns the value for the member attribute <b>version</b>
- *
- * @return Date - value of member attribute <b>version</b> .
- */
- public Long getVersion() {
- return this.version;
- }
-
- /**
- * This method sets the value to the member attribute <b> name</b> . You
- * cannot set null to the attribute.
- *
- * @param name
- * Value to set member attribute <b> name</b>
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * Returns the value for the member attribute <b>name</b>
- *
- * @return Date - value of member attribute <b>name</b> .
- */
- public String getName() {
- return this.name;
- }
-
- /**
- * This method sets the value to the member attribute <b> implClassName</b>
- * . You cannot set null to the attribute.
- *
- * @param implClassName
- * Value to set member attribute <b> implClassName</b>
- */
- public void setImplclassname(String implClassName) {
- this.implClassName = implClassName;
- }
-
- /**
- * Returns the value for the member attribute <b>implClassName</b>
- *
- * @return Date - value of member attribute <b>implClassName</b> .
- */
- public String getImplclassname() {
- return this.implClassName;
- }
-
- /**
- * This method sets the value to the member attribute <b> label</b> . You
- * cannot set null to the attribute.
- *
- * @param label
- * Value to set member attribute <b> label</b>
- */
- public void setLabel(String label) {
- this.label = label;
- }
-
- /**
- * Returns the value for the member attribute <b>label</b>
- *
- * @return Date - value of member attribute <b>label</b> .
- */
- public String getLabel() {
- return this.label;
- }
-
- /**
- * This method sets the value to the member attribute <b> description</b> .
- * You cannot set null to the attribute.
- *
- * @param description
- * Value to set member attribute <b> description</b>
- */
- public void setDescription(String description) {
- this.description = description;
- }
-
- /**
- * Returns the value for the member attribute <b>description</b>
- *
- * @return Date - value of member attribute <b>description</b> .
- */
- public String getDescription() {
- return this.description;
- }
-
- /**
- * This method sets the value to the member attribute <b> rbKeyLabel</b> .
- * You cannot set null to the attribute.
- *
- * @param rbKeyLabel
- * Value to set member attribute <b> rbKeyLabel</b>
- */
- public void setRbkeylabel(String rbKeyLabel) {
- this.rbKeyLabel = rbKeyLabel;
- }
-
- /**
- * Returns the value for the member attribute <b>rbKeyLabel</b>
- *
- * @return Date - value of member attribute <b>rbKeyLabel</b> .
- */
- public String getRbkeylabel() {
- return this.rbKeyLabel;
- }
-
- /**
- * This method sets the value to the member attribute <b>
- * rbKeyDescription</b> . You cannot set null to the attribute.
- *
- * @param rbKeyDescription
- * Value to set member attribute <b> rbKeyDescription</b>
- */
- public void setRbkeydescription(String rbKeyDescription) {
- this.rbKeyDescription = rbKeyDescription;
- }
-
- /**
- * Returns the value for the member attribute <b>rbKeyDescription</b>
- *
- * @return Date - value of member attribute <b>rbKeyDescription</b> .
- */
- public String getRbkeydescription() {
- return this.rbKeyDescription;
- }
-
- /**
- * This method sets the value to the member attribute <b> isEnabled</b> .
- * You cannot set null to the attribute.
- *
- * @param isEnabled
- * Value to set member attribute <b> isEnabled</b>
- */
- public void setIsEnabled(boolean isEnabled) {
- this.isEnabled = isEnabled;
- }
-
- /**
- * Returns the value for the member attribute <b>isEnabled</b>
- *
- * @return Date - value of member attribute <b>isEnabled</b> .
- */
- public boolean getIsEnabled() {
- return this.isEnabled;
+ @Override
+ public String toString() {
+ return "XXServiceDef [id=" + id + "]";
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(Object obj) {
- if (!super.equals(obj)) {
- return false;
- }
- if (this == obj) {
+ if (this == obj)
return true;
- }
- if (getClass() != obj.getClass()) {
+ if (!super.equals(obj))
return false;
- }
- XXServiceDef other = (XXServiceDef) obj;
- if (description == null) {
- if (other.description != null) {
- return false;
- }
- } else if (!description.equals(other.description)) {
+ if (getClass() != obj.getClass())
return false;
- }
+ XXServiceDefWithAssignedId other = (XXServiceDefWithAssignedId) obj;
if (id == null) {
- if (other.id != null) {
- return false;
- }
- } else if (!id.equals(other.id)) {
- return false;
- }
- if (guid == null) {
- if (other.guid != null) {
- return false;
- }
- } else if (!guid.equals(other.guid)) {
- return false;
- }
- if (implClassName == null) {
- if (other.implClassName != null) {
- return false;
- }
- } else if (!implClassName.equals(other.implClassName)) {
- return false;
- }
- if (label == null) {
- if (other.label != null) {
- return false;
- }
- } else if (!label.equals(other.label)) {
- return false;
- }
- if (name == null) {
- if (other.name != null) {
- return false;
- }
- } else if (!name.equals(other.name)) {
- return false;
- }
- if (rbKeyDescription == null) {
- if (other.rbKeyDescription != null) {
- return false;
- }
- } else if (!rbKeyDescription.equals(other.rbKeyDescription)) {
- return false;
- }
- if (rbKeyLabel == null) {
- if (other.rbKeyLabel != null) {
+ if (other.id != null)
return false;
- }
- } else if (!rbKeyLabel.equals(other.rbKeyLabel)) {
+ } else if (!id.equals(other.id))
return false;
- }
- if (version == null) {
- if (other.version != null) {
- return false;
- }
- } else if (!version.equals(other.version)) {
- return false;
- }
- if (isEnabled == null) {
- if (other.isEnabled != null) {
- return false;
- }
- } else if (!isEnabled.equals(other.isEnabled)) {
- return false;
- }
return true;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "XXServiceDef [" + super.toString() + " id=" + id + ", guid="
- + guid + ", version=" + version + ", name=" + name
- + ", implClassName=" + implClassName + ", label=" + label
- + ", description=" + description + ", rbKeyLabel=" + rbKeyLabel
- + ", rbKeyDescription=" + rbKeyDescription + ", isEnabled"
- + isEnabled + "]";
- }
-
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/de019a80/security-admin/src/main/java/org/apache/ranger/entity/XXServiceDefBase.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXServiceDefBase.java b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceDefBase.java
new file mode 100644
index 0000000..93a0372
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceDefBase.java
@@ -0,0 +1,375 @@
+/*
+ * 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.Column;
+import javax.persistence.MappedSuperclass;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@MappedSuperclass
+@XmlRootElement
+public abstract class XXServiceDefBase extends XXDBBase implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Global Id for the object
+ * <ul>
+ * <li>The maximum length for this attribute is <b>512</b>.
+ * </ul>
+ *
+ */
+ @Column(name = "guid", unique = true, nullable = false, length = 512)
+ protected String guid;
+ /**
+ * version of the XXServiceDef
+ * <ul>
+ * </ul>
+ *
+ */
+ @Column(name = "version")
+ protected Long version;
+
+ /**
+ * name of the XXServiceDef
+ * <ul>
+ * </ul>
+ *
+ */
+ @Column(name = "name")
+ protected String name;
+
+ /**
+ * implClassName of the XXServiceDef
+ * <ul>
+ * </ul>
+ *
+ */
+ @Column(name = "impl_class_name")
+ protected String implClassName;
+
+ /**
+ * label of the XXServiceDef
+ * <ul>
+ * </ul>
+ *
+ */
+ @Column(name = "label")
+ protected String label;
+
+ /**
+ * description of the XXServiceDef
+ * <ul>
+ * </ul>
+ *
+ */
+ @Column(name = "description")
+ protected String description;
+
+ /**
+ * rbKeyLabel of the XXServiceDef
+ * <ul>
+ * </ul>
+ *
+ */
+ @Column(name = "rb_key_label")
+ protected String rbKeyLabel;
+
+ /**
+ * rbKeyDescription of the XXServiceDef
+ * <ul>
+ * </ul>
+ *
+ */
+ @Column(name = "rb_key_description")
+ protected String rbKeyDescription;
+ /**
+ * isEnabled of the XXPolicy
+ * <ul>
+ * </ul>
+ *
+ */
+ @Column(name = "is_enabled")
+ protected Boolean isEnabled;
+
+ /**
+ * @return the gUID
+ */
+ public String getGuid() {
+ return this.guid;
+ }
+
+ /**
+ * @param guid
+ * the gUID to set
+ */
+ public void setGuid(String guid) {
+ this.guid = guid;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b> version</b> . You cannot set null to the attribute.
+ *
+ * @param version
+ * Value to set member attribute <b> version</b>
+ */
+ public void setVersion(Long version) {
+ this.version = version;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>version</b>
+ *
+ * @return Date - value of member attribute <b>version</b> .
+ */
+ public Long getVersion() {
+ return this.version;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b> name</b> . You cannot set null to the attribute.
+ *
+ * @param name
+ * Value to set member attribute <b> name</b>
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>name</b>
+ *
+ * @return Date - value of member attribute <b>name</b> .
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b> implClassName</b> . You cannot set null to the attribute.
+ *
+ * @param implClassName
+ * Value to set member attribute <b> implClassName</b>
+ */
+ public void setImplclassname(String implClassName) {
+ this.implClassName = implClassName;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>implClassName</b>
+ *
+ * @return Date - value of member attribute <b>implClassName</b> .
+ */
+ public String getImplclassname() {
+ return this.implClassName;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b> label</b> . You cannot set null to the attribute.
+ *
+ * @param label
+ * Value to set member attribute <b> label</b>
+ */
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>label</b>
+ *
+ * @return Date - value of member attribute <b>label</b> .
+ */
+ public String getLabel() {
+ return this.label;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b> description</b> . You cannot set null to the attribute.
+ *
+ * @param description
+ * Value to set member attribute <b> description</b>
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>description</b>
+ *
+ * @return Date - value of member attribute <b>description</b> .
+ */
+ public String getDescription() {
+ return this.description;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b> rbKeyLabel</b> . You cannot set null to the attribute.
+ *
+ * @param rbKeyLabel
+ * Value to set member attribute <b> rbKeyLabel</b>
+ */
+ public void setRbkeylabel(String rbKeyLabel) {
+ this.rbKeyLabel = rbKeyLabel;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>rbKeyLabel</b>
+ *
+ * @return Date - value of member attribute <b>rbKeyLabel</b> .
+ */
+ public String getRbkeylabel() {
+ return this.rbKeyLabel;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b> rbKeyDescription</b> . You cannot set null to the
+ * attribute.
+ *
+ * @param rbKeyDescription
+ * Value to set member attribute <b> rbKeyDescription</b>
+ */
+ public void setRbkeydescription(String rbKeyDescription) {
+ this.rbKeyDescription = rbKeyDescription;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>rbKeyDescription</b>
+ *
+ * @return Date - value of member attribute <b>rbKeyDescription</b> .
+ */
+ public String getRbkeydescription() {
+ return this.rbKeyDescription;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b> isEnabled</b> . You cannot set null to the attribute.
+ *
+ * @param isEnabled
+ * Value to set member attribute <b> isEnabled</b>
+ */
+ public void setIsEnabled(boolean isEnabled) {
+ this.isEnabled = isEnabled;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>isEnabled</b>
+ *
+ * @return Date - value of member attribute <b>isEnabled</b> .
+ */
+ public boolean getIsEnabled() {
+ return this.isEnabled;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (this == obj) {
+ return true;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ XXServiceDefBase other = (XXServiceDefBase) obj;
+ if (description == null) {
+ if (other.description != null) {
+ return false;
+ }
+ } else if (!description.equals(other.description)) {
+ return false;
+ }
+ if (guid == null) {
+ if (other.guid != null) {
+ return false;
+ }
+ } else if (!guid.equals(other.guid)) {
+ return false;
+ }
+ if (implClassName == null) {
+ if (other.implClassName != null) {
+ return false;
+ }
+ } else if (!implClassName.equals(other.implClassName)) {
+ return false;
+ }
+ if (label == null) {
+ if (other.label != null) {
+ return false;
+ }
+ } else if (!label.equals(other.label)) {
+ return false;
+ }
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+ if (rbKeyDescription == null) {
+ if (other.rbKeyDescription != null) {
+ return false;
+ }
+ } else if (!rbKeyDescription.equals(other.rbKeyDescription)) {
+ return false;
+ }
+ if (rbKeyLabel == null) {
+ if (other.rbKeyLabel != null) {
+ return false;
+ }
+ } else if (!rbKeyLabel.equals(other.rbKeyLabel)) {
+ return false;
+ }
+ if (version == null) {
+ if (other.version != null) {
+ return false;
+ }
+ } else if (!version.equals(other.version)) {
+ return false;
+ }
+ if (isEnabled == null) {
+ if (other.isEnabled != null) {
+ return false;
+ }
+ } else if (!isEnabled.equals(other.isEnabled)) {
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "XXServiceDefBase [" + super.toString() + " guid=" + guid + ", version=" + version + ", name=" + name
+ + ", implClassName=" + implClassName + ", label=" + label + ", description=" + description
+ + ", rbKeyLabel=" + rbKeyLabel + ", rbKeyDescription=" + rbKeyDescription + ", isEnabled" + isEnabled
+ + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/de019a80/security-admin/src/main/java/org/apache/ranger/entity/XXServiceDefWithAssignedId.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXServiceDefWithAssignedId.java b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceDefWithAssignedId.java
new file mode 100644
index 0000000..1cab8fe
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceDefWithAssignedId.java
@@ -0,0 +1,76 @@
+/*
+ * 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 javax.persistence.Cacheable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@Entity
+@Cacheable
+@XmlRootElement
+@Table(name = "x_service_def")
+public class XXServiceDefWithAssignedId extends XXServiceDefBase {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * id of the XXService
+ * <ul>
+ * </ul>
+ *
+ */
+ @Id
+ @Column(name = "id")
+ protected Long id;
+
+ @Override
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ @Override
+ public Long getId() {
+ return id;
+ }
+
+ @Override
+ public String toString() {
+ return "XXServiceDefWithAssignedId [id=" + id + "]";
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ XXServiceDefWithAssignedId other = (XXServiceDefWithAssignedId) obj;
+ if (id == null) {
+ if (other.id != null)
+ return false;
+ } else if (!id.equals(other.id))
+ return false;
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/de019a80/security-admin/src/main/java/org/apache/ranger/service/RangerServiceDefService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/service/RangerServiceDefService.java b/security-admin/src/main/java/org/apache/ranger/service/RangerServiceDefService.java
index 4970ffe..9f9761c 100644
--- a/security-admin/src/main/java/org/apache/ranger/service/RangerServiceDefService.java
+++ b/security-admin/src/main/java/org/apache/ranger/service/RangerServiceDefService.java
@@ -20,29 +20,9 @@ package org.apache.ranger.service;
import java.util.ArrayList;
import java.util.List;
-import org.apache.ranger.common.ContextUtil;
-import org.apache.ranger.common.RangerConstants;
-import org.apache.ranger.common.SearchField;
-import org.apache.ranger.common.SortField;
-import org.apache.ranger.common.SearchField.DATA_TYPE;
-import org.apache.ranger.common.SearchField.SEARCH_TYPE;
-import org.apache.ranger.common.UserSessionBase;
-import org.apache.ranger.entity.XXContextEnricherDef;
-import org.apache.ranger.entity.XXAccessTypeDef;
-import org.apache.ranger.entity.XXEnumDef;
-import org.apache.ranger.entity.XXPolicyConditionDef;
-import org.apache.ranger.entity.XXResourceDef;
-import org.apache.ranger.entity.XXServiceConfigDef;
import org.apache.ranger.entity.XXServiceDef;
+import org.apache.ranger.entity.XXServiceDefBase;
import org.apache.ranger.plugin.model.RangerServiceDef;
-import org.apache.ranger.plugin.model.RangerServiceDef.RangerAccessTypeDef;
-import org.apache.ranger.plugin.model.RangerServiceDef.RangerContextEnricherDef;
-import org.apache.ranger.plugin.model.RangerServiceDef.RangerEnumDef;
-import org.apache.ranger.plugin.model.RangerServiceDef.RangerPolicyConditionDef;
-import org.apache.ranger.plugin.model.RangerServiceDef.RangerResourceDef;
-import org.apache.ranger.plugin.model.RangerServiceDef.RangerServiceConfigDef;
-import org.apache.ranger.plugin.util.SearchFilter;
-import org.apache.ranger.view.RangerServiceDefList;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
@@ -52,147 +32,40 @@ public class RangerServiceDefService extends RangerServiceDefServiceBase<XXServi
public RangerServiceDefService() {
super();
-
- searchFields.add(new SearchField(SearchFilter.SERVICE_TYPE, "obj.name", DATA_TYPE.STRING, SEARCH_TYPE.FULL));
- searchFields.add(new SearchField(SearchFilter.SERVICE_TYPE_ID, "obj.id", DATA_TYPE.INTEGER, SEARCH_TYPE.FULL));
- searchFields.add(new SearchField(SearchFilter.IS_ENABLED, "obj.isEnabled", DATA_TYPE.BOOLEAN, SEARCH_TYPE.FULL));
-
- sortFields.add(new SortField(SearchFilter.CREATE_TIME, "obj.createTime"));
- sortFields.add(new SortField(SearchFilter.UPDATE_TIME, "obj.updateTime"));
- sortFields.add(new SortField(SearchFilter.SERVICE_TYPE_ID, "obj.id"));
- sortFields.add(new SortField(SearchFilter.SERVICE_TYPE, "obj.name"));
}
@Override
protected void validateForCreate(RangerServiceDef vObj) {
- // TODO Auto-generated method stub
}
@Override
- protected void validateForUpdate(RangerServiceDef vObj,
- XXServiceDef entityObj) {
- // TODO Auto-generated method stub
+ protected void validateForUpdate(RangerServiceDef vObj, XXServiceDef entityObj) {
}
-
@Override
- protected RangerServiceDef populateViewBean(XXServiceDef xServiceDef) {
- RangerServiceDef serviceDef = super.populateViewBean(xServiceDef);
- Long serviceDefId = xServiceDef.getId();
-
- List<XXServiceConfigDef> xConfigs = daoMgr.getXXServiceConfigDef().findByServiceDefId(serviceDefId);
- if (!stringUtil.isEmpty(xConfigs)) {
- List<RangerServiceConfigDef> configs = new ArrayList<RangerServiceConfigDef>();
- for (XXServiceConfigDef xConfig : xConfigs) {
- RangerServiceConfigDef config = populateXXToRangerServiceConfigDef(xConfig);
- configs.add(config);
- }
- serviceDef.setConfigs(configs);
- }
-
- List<XXResourceDef> xResources = daoMgr.getXXResourceDef().findByServiceDefId(serviceDefId);
- if(!stringUtil.isEmpty(xResources)) {
- List<RangerResourceDef> resources = new ArrayList<RangerResourceDef>();
- for(XXResourceDef xResource : xResources) {
- RangerResourceDef resource = populateXXToRangerResourceDef(xResource);
- resources.add(resource);
- }
- serviceDef.setResources(resources);
- }
-
- List<XXAccessTypeDef> xAccessTypes = daoMgr.getXXAccessTypeDef().findByServiceDefId(serviceDefId);
- if(!stringUtil.isEmpty(xAccessTypes)) {
- List<RangerAccessTypeDef> accessTypes = new ArrayList<RangerAccessTypeDef>();
- for(XXAccessTypeDef xAtd : xAccessTypes) {
- RangerAccessTypeDef accessType = populateXXToRangerAccessTypeDef(xAtd);
- accessTypes.add(accessType);
- }
- serviceDef.setAccessTypes(accessTypes);
- }
-
- List<XXPolicyConditionDef> xPolicyConditions = daoMgr.getXXPolicyConditionDef().findByServiceDefId(serviceDefId);
- if(!stringUtil.isEmpty(xPolicyConditions)) {
- List<RangerPolicyConditionDef> policyConditions = new ArrayList<RangerServiceDef.RangerPolicyConditionDef>();
- for(XXPolicyConditionDef xPolicyCondDef : xPolicyConditions) {
- RangerPolicyConditionDef policyCondition = populateXXToRangerPolicyConditionDef(xPolicyCondDef);
- policyConditions.add(policyCondition);
- }
- serviceDef.setPolicyConditions(policyConditions);
- }
-
- List<XXContextEnricherDef> xContextEnrichers = daoMgr.getXXContextEnricherDef().findByServiceDefId(serviceDefId);
- if(!stringUtil.isEmpty(xContextEnrichers)) {
- List<RangerContextEnricherDef> contextEnrichers = new ArrayList<RangerServiceDef.RangerContextEnricherDef>();
- for(XXContextEnricherDef xContextEnricherDef : xContextEnrichers) {
- RangerContextEnricherDef contextEnricher = populateXXToRangerContextEnricherDef(xContextEnricherDef);
- contextEnrichers.add(contextEnricher);
- }
- serviceDef.setContextEnrichers(contextEnrichers);
- }
-
- List<XXEnumDef> xEnumList = daoMgr.getXXEnumDef().findByServiceDefId(serviceDefId);
- if(!stringUtil.isEmpty(xEnumList)) {
- List<RangerEnumDef> enums = new ArrayList<RangerEnumDef>();
- for(XXEnumDef xEnum : xEnumList) {
- RangerEnumDef vEnum = populateXXToRangerEnumDef(xEnum);
- enums.add(vEnum);
- }
- serviceDef.setEnums(enums);
- }
- return serviceDef;
+ protected XXServiceDef mapViewToEntityBean(RangerServiceDef vObj, XXServiceDef xObj, int OPERATION_CONTEXT) {
+ return (XXServiceDef) super.mapViewToEntityBean(vObj, (XXServiceDefBase) xObj, OPERATION_CONTEXT);
}
-
+
+ @Override
+ protected RangerServiceDef mapEntityToViewBean(RangerServiceDef vObj, XXServiceDef xObj) {
+ return super.mapEntityToViewBean(vObj, (XXServiceDefBase) xObj);
+ }
+
public List<RangerServiceDef> getAllServiceDefs() {
List<XXServiceDef> xxServiceDefList = daoMgr.getXXServiceDef().getAll();
List<RangerServiceDef> serviceDefList = new ArrayList<RangerServiceDef>();
-
- for(XXServiceDef xxServiceDef : xxServiceDefList) {
+
+ for (XXServiceDef xxServiceDef : xxServiceDefList) {
RangerServiceDef serviceDef = populateViewBean(xxServiceDef);
serviceDefList.add(serviceDef);
}
return serviceDefList;
}
-
+
public RangerServiceDef getPopulatedViewObject(XXServiceDef xServiceDef) {
return this.populateViewBean(xServiceDef);
}
- @Override
- public RangerServiceDefList searchRangerServiceDefs(SearchFilter searchFilter) {
- //List<RangerServiceDef> serviceDefList = new ArrayList<RangerServiceDef>();
- RangerServiceDefList retList = new RangerServiceDefList();
- int startIndex = searchFilter.getStartIndex();
- int pageSize = searchFilter.getMaxRows();
- searchFilter.setStartIndex(0);
- searchFilter.setMaxRows(Integer.MAX_VALUE);
- List<XXServiceDef> xSvcDefList = (List<XXServiceDef>) searchResources(searchFilter, searchFields, sortFields, retList);
- UserSessionBase sessionBase = ContextUtil.getCurrentUserSession();
- //List<String> userRoleList = (sessionBase != null) ? sessionBase.getUserRoleList() : null;
- List<XXServiceDef> permittedServiceDefs = new ArrayList<XXServiceDef>();
- for (XXServiceDef xSvcDef : xSvcDefList) {
- if(bizUtil.hasAccess(xSvcDef, null)){
- permittedServiceDefs.add(xSvcDef);
- }
- }
- //retList.setServiceDefs(serviceDefList);
- if(permittedServiceDefs.size() > 0) {
- populatePageList(permittedServiceDefs, startIndex, pageSize, retList);
- }
- return retList;
- }
-
- private void populatePageList(List<XXServiceDef> xxObjList, int startIndex, int pageSize,
- RangerServiceDefList retList) {
- List<RangerServiceDef> onePageList = new ArrayList<RangerServiceDef>();
-
- for (int i = startIndex; i < pageSize + startIndex && i < xxObjList.size(); i++) {
- onePageList.add(populateViewBean(xxObjList.get(i)));
- }
- retList.setServiceDefs(onePageList);
- retList.setStartIndex(startIndex);
- retList.setPageSize(pageSize);
- retList.setResultSize(onePageList.size());
- retList.setTotalCount(xxObjList.size());
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/de019a80/security-admin/src/main/java/org/apache/ranger/service/RangerServiceDefServiceBase.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/service/RangerServiceDefServiceBase.java b/security-admin/src/main/java/org/apache/ranger/service/RangerServiceDefServiceBase.java
index f6a24aa..dac9807 100644
--- a/security-admin/src/main/java/org/apache/ranger/service/RangerServiceDefServiceBase.java
+++ b/security-admin/src/main/java/org/apache/ranger/service/RangerServiceDefServiceBase.java
@@ -29,6 +29,10 @@ import org.apache.ranger.common.AppConstants;
import org.apache.ranger.common.GUIDUtil;
import org.apache.ranger.common.JSONUtil;
import org.apache.ranger.common.MessageEnums;
+import org.apache.ranger.common.SearchField;
+import org.apache.ranger.common.SortField;
+import org.apache.ranger.common.SearchField.DATA_TYPE;
+import org.apache.ranger.common.SearchField.SEARCH_TYPE;
import org.apache.ranger.entity.XXAccessTypeDef;
import org.apache.ranger.entity.XXContextEnricherDef;
import org.apache.ranger.entity.XXDBBase;
@@ -38,6 +42,7 @@ import org.apache.ranger.entity.XXPolicyConditionDef;
import org.apache.ranger.entity.XXResourceDef;
import org.apache.ranger.entity.XXServiceConfigDef;
import org.apache.ranger.entity.XXServiceDef;
+import org.apache.ranger.entity.XXServiceDefBase;
import org.apache.ranger.plugin.model.RangerServiceDef;
import org.apache.ranger.plugin.model.RangerServiceDef.RangerAccessTypeDef;
import org.apache.ranger.plugin.model.RangerServiceDef.RangerContextEnricherDef;
@@ -50,7 +55,7 @@ import org.apache.ranger.plugin.util.SearchFilter;
import org.apache.ranger.view.RangerServiceDefList;
import org.springframework.beans.factory.annotation.Autowired;
-public abstract class RangerServiceDefServiceBase<T extends XXServiceDef, V extends RangerServiceDef>
+public abstract class RangerServiceDefServiceBase<T extends XXServiceDefBase, V extends RangerServiceDef>
extends RangerBaseModelService<T, V> {
private static final Log LOG = LogFactory.getLog(RangerServiceDefServiceBase.class);
@@ -63,9 +68,92 @@ public abstract class RangerServiceDefServiceBase<T extends XXServiceDef, V exte
@Autowired
GUIDUtil guidUtil;
+ public RangerServiceDefServiceBase() {
+ super();
+
+ searchFields.add(new SearchField(SearchFilter.SERVICE_TYPE, "obj.name", DATA_TYPE.STRING, SEARCH_TYPE.FULL));
+ searchFields.add(new SearchField(SearchFilter.SERVICE_TYPE_ID, "obj.id", DATA_TYPE.INTEGER, SEARCH_TYPE.FULL));
+ searchFields.add(new SearchField(SearchFilter.IS_ENABLED, "obj.isEnabled", DATA_TYPE.BOOLEAN, SEARCH_TYPE.FULL));
+
+ sortFields.add(new SortField(SearchFilter.CREATE_TIME, "obj.createTime"));
+ sortFields.add(new SortField(SearchFilter.UPDATE_TIME, "obj.updateTime"));
+ sortFields.add(new SortField(SearchFilter.SERVICE_TYPE_ID, "obj.id"));
+ sortFields.add(new SortField(SearchFilter.SERVICE_TYPE, "obj.name"));
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ protected RangerServiceDef populateViewBean(XXServiceDefBase xServiceDef) {
+ RangerServiceDef serviceDef = super.populateViewBean((T) xServiceDef);
+ Long serviceDefId = xServiceDef.getId();
+
+ List<XXServiceConfigDef> xConfigs = daoMgr.getXXServiceConfigDef().findByServiceDefId(serviceDefId);
+ if (!stringUtil.isEmpty(xConfigs)) {
+ List<RangerServiceConfigDef> configs = new ArrayList<RangerServiceConfigDef>();
+ for (XXServiceConfigDef xConfig : xConfigs) {
+ RangerServiceConfigDef config = populateXXToRangerServiceConfigDef(xConfig);
+ configs.add(config);
+ }
+ serviceDef.setConfigs(configs);
+ }
+
+ List<XXResourceDef> xResources = daoMgr.getXXResourceDef().findByServiceDefId(serviceDefId);
+ if (!stringUtil.isEmpty(xResources)) {
+ List<RangerResourceDef> resources = new ArrayList<RangerResourceDef>();
+ for (XXResourceDef xResource : xResources) {
+ RangerResourceDef resource = populateXXToRangerResourceDef(xResource);
+ resources.add(resource);
+ }
+ serviceDef.setResources(resources);
+ }
+
+ List<XXAccessTypeDef> xAccessTypes = daoMgr.getXXAccessTypeDef().findByServiceDefId(serviceDefId);
+ if (!stringUtil.isEmpty(xAccessTypes)) {
+ List<RangerAccessTypeDef> accessTypes = new ArrayList<RangerAccessTypeDef>();
+ for (XXAccessTypeDef xAtd : xAccessTypes) {
+ RangerAccessTypeDef accessType = populateXXToRangerAccessTypeDef(xAtd);
+ accessTypes.add(accessType);
+ }
+ serviceDef.setAccessTypes(accessTypes);
+ }
+
+ List<XXPolicyConditionDef> xPolicyConditions = daoMgr.getXXPolicyConditionDef()
+ .findByServiceDefId(serviceDefId);
+ if (!stringUtil.isEmpty(xPolicyConditions)) {
+ List<RangerPolicyConditionDef> policyConditions = new ArrayList<RangerServiceDef.RangerPolicyConditionDef>();
+ for (XXPolicyConditionDef xPolicyCondDef : xPolicyConditions) {
+ RangerPolicyConditionDef policyCondition = populateXXToRangerPolicyConditionDef(xPolicyCondDef);
+ policyConditions.add(policyCondition);
+ }
+ serviceDef.setPolicyConditions(policyConditions);
+ }
+
+ List<XXContextEnricherDef> xContextEnrichers = daoMgr.getXXContextEnricherDef()
+ .findByServiceDefId(serviceDefId);
+ if (!stringUtil.isEmpty(xContextEnrichers)) {
+ List<RangerContextEnricherDef> contextEnrichers = new ArrayList<RangerServiceDef.RangerContextEnricherDef>();
+ for (XXContextEnricherDef xContextEnricherDef : xContextEnrichers) {
+ RangerContextEnricherDef contextEnricher = populateXXToRangerContextEnricherDef(xContextEnricherDef);
+ contextEnrichers.add(contextEnricher);
+ }
+ serviceDef.setContextEnrichers(contextEnrichers);
+ }
+
+ List<XXEnumDef> xEnumList = daoMgr.getXXEnumDef().findByServiceDefId(serviceDefId);
+ if (!stringUtil.isEmpty(xEnumList)) {
+ List<RangerEnumDef> enums = new ArrayList<RangerEnumDef>();
+ for (XXEnumDef xEnum : xEnumList) {
+ RangerEnumDef vEnum = populateXXToRangerEnumDef(xEnum);
+ enums.add(vEnum);
+ }
+ serviceDef.setEnums(enums);
+ }
+ return serviceDef;
+ }
+
@SuppressWarnings("unchecked")
@Override
- protected XXServiceDef mapViewToEntityBean(RangerServiceDef vObj, XXServiceDef xObj, int operationContext) {
+ protected XXServiceDefBase mapViewToEntityBean(RangerServiceDef vObj, XXServiceDefBase xObj, int operationContext) {
String guid = (StringUtils.isEmpty(vObj.getGuid())) ? guidUtil.genGUID() : vObj.getGuid();
@@ -83,7 +171,7 @@ public abstract class RangerServiceDefServiceBase<T extends XXServiceDef, V exte
@SuppressWarnings("unchecked")
@Override
- protected RangerServiceDef mapEntityToViewBean(RangerServiceDef vObj, XXServiceDef xObj) {
+ protected RangerServiceDef mapEntityToViewBean(RangerServiceDef vObj, XXServiceDefBase xObj) {
vObj.setGuid(xObj.getGuid());
vObj.setVersion(xObj.getVersion());
vObj.setName(xObj.getName());
@@ -359,19 +447,40 @@ public abstract class RangerServiceDefServiceBase<T extends XXServiceDef, V exte
@SuppressWarnings("unchecked")
public RangerServiceDefList searchRangerServiceDefs(SearchFilter searchFilter) {
- List<RangerServiceDef> serviceDefList = new ArrayList<RangerServiceDef>();
RangerServiceDefList retList = new RangerServiceDefList();
-
- List<XXServiceDef> xSvcDefList = (List<XXServiceDef>) searchResources(searchFilter, searchFields, sortFields, retList);
+ int startIndex = searchFilter.getStartIndex();
+ int pageSize = searchFilter.getMaxRows();
+ searchFilter.setStartIndex(0);
+ searchFilter.setMaxRows(Integer.MAX_VALUE);
+ List<XXServiceDef> xSvcDefList = (List<XXServiceDef>) searchResources(searchFilter, searchFields, sortFields,
+ retList);
+ List<XXServiceDef> permittedServiceDefs = new ArrayList<XXServiceDef>();
for (XXServiceDef xSvcDef : xSvcDefList) {
- serviceDefList.add(populateViewBean((T) xSvcDef));
+ if (bizUtil.hasAccess(xSvcDef, null)) {
+ permittedServiceDefs.add(xSvcDef);
+ }
+ }
+ if (permittedServiceDefs.size() > 0) {
+ populatePageList(permittedServiceDefs, startIndex, pageSize, retList);
}
-
- retList.setServiceDefs(serviceDefList);
-
return retList;
+
}
+ private void populatePageList(List<XXServiceDef> xxObjList, int startIndex, int pageSize,
+ RangerServiceDefList retList) {
+ List<RangerServiceDef> onePageList = new ArrayList<RangerServiceDef>();
+
+ for (int i = startIndex; i < pageSize + startIndex && i < xxObjList.size(); i++) {
+ onePageList.add(populateViewBean(xxObjList.get(i)));
+ }
+ retList.setServiceDefs(onePageList);
+ retList.setStartIndex(startIndex);
+ retList.setPageSize(pageSize);
+ retList.setResultSize(onePageList.size());
+ retList.setTotalCount(xxObjList.size());
+ }
+
private String mapToJsonString(Map<String, String> map) {
String ret = null;
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/de019a80/security-admin/src/main/java/org/apache/ranger/service/RangerServiceDefWithAssignedIdService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/service/RangerServiceDefWithAssignedIdService.java b/security-admin/src/main/java/org/apache/ranger/service/RangerServiceDefWithAssignedIdService.java
new file mode 100644
index 0000000..7fc54b1
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/service/RangerServiceDefWithAssignedIdService.java
@@ -0,0 +1,58 @@
+/*
+ * 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.service;
+
+import org.apache.ranger.entity.XXServiceDefBase;
+import org.apache.ranger.entity.XXServiceDefWithAssignedId;
+import org.apache.ranger.plugin.model.RangerServiceDef;
+import org.springframework.stereotype.Service;
+
+@Service
+public class RangerServiceDefWithAssignedIdService extends RangerServiceDefServiceBase<XXServiceDefWithAssignedId, RangerServiceDef> {
+
+ @Override
+ protected XXServiceDefWithAssignedId mapViewToEntityBean(RangerServiceDef vObj, XXServiceDefWithAssignedId xObj,
+ int OPERATION_CONTEXT) {
+ return (XXServiceDefWithAssignedId) super.mapViewToEntityBean(vObj, (XXServiceDefBase) xObj, OPERATION_CONTEXT);
+ }
+
+ @Override
+ protected RangerServiceDef mapEntityToViewBean(RangerServiceDef vObj, XXServiceDefWithAssignedId xObj) {
+ return super.mapEntityToViewBean(vObj, (XXServiceDefBase) xObj);
+ }
+
+ @Override
+ protected void validateForCreate(RangerServiceDef vObj) {
+
+ }
+
+ @Override
+ protected void validateForUpdate(RangerServiceDef vServiceDef, XXServiceDefWithAssignedId xServiceDef) {
+
+ }
+
+ @Override
+ protected RangerServiceDef populateViewBean(XXServiceDefWithAssignedId xServiceDef) {
+ return super.populateViewBean(xServiceDef);
+ }
+
+ public RangerServiceDef getPopulatedViewObject(XXServiceDefWithAssignedId xServiceDef) {
+ return this.populateViewBean(xServiceDef);
+ }
+
+}