ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From v..@apache.org
Subject [2/2] incubator-ranger git commit: RANGER-200: Pagination on Analytics Page (Gautam Borad via Velmurugan Periasamy)
Date Fri, 20 Mar 2015 08:19:21 GMT
RANGER-200: Pagination on Analytics Page (Gautam Borad via Velmurugan Periasamy)


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

Branch: refs/heads/master
Commit: 85d5658fc205a647bb397ee83d81df4cbaa5f53d
Parents: 4bf8a3f
Author: Velmurugan Periasamy <vel@apache.org>
Authored: Fri Mar 20 04:18:15 2015 -0400
Committer: Velmurugan Periasamy <vel@apache.org>
Committed: Fri Mar 20 04:18:15 2015 -0400

----------------------------------------------------------------------
 .../apache/ranger/plugin/util/SearchFilter.java |    2 +
 .../org/apache/ranger/biz/ServiceDBStore.java   |  171 ++-
 .../apache/ranger/common/RangerSearchUtil.java  |   86 ++
 .../org/apache/ranger/db/XXDataHistDao.java     |   18 +
 .../org/apache/ranger/rest/ServiceREST.java     |  260 +++-
 .../ranger/service/RangerDataHistService.java   |   19 +-
 .../ranger/service/RangerPolicyService.java     |    4 +
 .../ranger/service/RangerPolicyServiceBase.java |   19 +-
 .../service/RangerServiceDefServiceBase.java    |   20 +-
 .../service/RangerServiceServiceBase.java       |   18 +-
 .../apache/ranger/view/RangerPolicyList.java    |   55 +
 .../ranger/view/RangerServiceDefList.java       |   55 +
 .../apache/ranger/view/RangerServiceList.java   |   55 +
 .../collection_bases/RangerPolicyListBase.js    |    8 +-
 .../RangerServiceDefListBase.js                 |    9 +-
 .../collection_bases/RangerServiceListBase.js   |    8 +-
 .../webapp/scripts/controllers/Controller.js    |   44 +-
 .../scripts/views/common/XATableLayout.js       |   12 +-
 .../scripts/views/policies/PermissionList.js    |   17 +-
 .../scripts/views/policies/RangerPolicyForm.js  |   10 +-
 .../scripts/views/reports/UserAccessLayout.js   | 1175 ++++--------------
 .../reports/UserAccessLayout_tmpl.html          |   55 +-
 22 files changed, 971 insertions(+), 1149 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/85d5658f/agents-common/src/main/java/org/apache/ranger/plugin/util/SearchFilter.java
----------------------------------------------------------------------
diff --git a/agents-common/src/main/java/org/apache/ranger/plugin/util/SearchFilter.java b/agents-common/src/main/java/org/apache/ranger/plugin/util/SearchFilter.java
index c669f23..86e5f7d 100644
--- a/agents-common/src/main/java/org/apache/ranger/plugin/util/SearchFilter.java
+++ b/agents-common/src/main/java/org/apache/ranger/plugin/util/SearchFilter.java
@@ -39,6 +39,8 @@ public class SearchFilter {
 	public static final String USER            = "user";          // search
 	public static final String GROUP           = "group";         // search
 	public static final String RESOURCE_PREFIX = "resource:";     // search
+	public static final String POL_RESOURCE    = "polResource";   // search
+	public static final String POLICY_NAME_PARTIAL = "policyNamePartial";    // search, sort
 	public static final String CREATE_TIME     = "createTime";    // sort
 	public static final String UPDATE_TIME     = "updateTime";    // sort
 	public static final String START_INDEX     = "startIndex";

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/85d5658f/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 2a30fd8..844a52e 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
@@ -32,6 +32,7 @@ import javax.annotation.PostConstruct;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.ranger.common.AppConstants;
 import org.apache.ranger.common.ContextUtil;
 import org.apache.ranger.common.DateUtil;
 import org.apache.ranger.common.MessageEnums;
@@ -60,6 +61,7 @@ import org.apache.ranger.entity.XXAccessTypeDef;
 import org.apache.ranger.entity.XXAccessTypeDefGrants;
 import org.apache.ranger.entity.XXContextEnricherDef;
 import org.apache.ranger.entity.XXDBBase;
+import org.apache.ranger.entity.XXDataHist;
 import org.apache.ranger.entity.XXEnumDef;
 import org.apache.ranger.entity.XXEnumElementDef;
 import org.apache.ranger.entity.XXGroup;
@@ -102,6 +104,9 @@ import org.apache.ranger.service.RangerPolicyService;
 import org.apache.ranger.service.RangerServiceDefService;
 import org.apache.ranger.service.RangerServiceService;
 import org.apache.ranger.service.XUserService;
+import org.apache.ranger.view.RangerPolicyList;
+import org.apache.ranger.view.RangerServiceDefList;
+import org.apache.ranger.view.RangerServiceList;
 import org.apache.ranger.view.VXUser;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
@@ -226,6 +231,9 @@ public class ServiceDBStore implements ServiceStore {
 		serviceDef.setCreateTime(null);
 		serviceDef.setUpdateTime(null);
 		
+		// While creating, value of version should be 1.
+		serviceDef.setVersion(new Long(1));
+		
 		serviceDef = serviceDefService.create(serviceDef);
 		Long serviceDefId = serviceDef.getId();
 		XXServiceDef createdSvcDef = daoMgr.getXXServiceDef().getById(serviceDefId);
@@ -377,21 +385,34 @@ public class ServiceDBStore implements ServiceStore {
 
 	@Override
 	public List<RangerServiceDef> getServiceDefs(SearchFilter filter) throws Exception {
-		if(LOG.isDebugEnabled()) {
+		if (LOG.isDebugEnabled()) {
 			LOG.debug("==> ServiceDBStore.getServiceDefs(" + filter + ")");
 		}
 
-		List<RangerServiceDef> ret = null;
+		RangerServiceDefList svcDefList = serviceDefService.searchRangerServiceDefs(filter);
+		List<RangerServiceDef> ret = svcDefList.getServiceDefs();
 
-		ret = serviceDefService.searchRangerServiceDefs(filter);
-
-		if(LOG.isDebugEnabled()) {
+		if (LOG.isDebugEnabled()) {
 			LOG.debug("==> ServiceDBStore.getServiceDefs(" + filter + "): " + ret);
 		}
 
 		return ret;
 	}
 
+	public RangerServiceDefList getPaginatedServiceDefs(SearchFilter filter) throws Exception {
+		if (LOG.isDebugEnabled()) {
+			LOG.debug("==> ServiceDBStore.getPaginatedServiceDefs(" + filter + ")");
+		}
+
+		RangerServiceDefList svcDefList = serviceDefService.searchRangerServiceDefs(filter);
+
+		if (LOG.isDebugEnabled()) {
+			LOG.debug("==> ServiceDBStore.getPaginatedServiceDefs(" + filter + ")");
+		}
+
+		return svcDefList;
+	}
+
 	@Override
 	public RangerService createService(RangerService service) throws Exception {
 		if (LOG.isDebugEnabled()) {
@@ -413,6 +434,9 @@ public class ServiceDBStore implements ServiceStore {
 						MessageEnums.ERROR_CREATING_OBJECT);
 			}
 
+			// While creating, value of version should be 1.
+			service.setVersion(new Long(1));
+			
 			if(populateExistingBaseFields) {
 				svcService.setPopulateExistingBaseFields(true);
 				service = svcService.create(service);
@@ -506,7 +530,16 @@ public class ServiceDBStore implements ServiceStore {
 		}
 		
 		List<XXTrxLog> trxLogList = svcService.getTransactionLog(service, existing, RangerServiceService.OPERATION_UPDATE_CONTEXT);
+	
+		Long version = service.getVersion();
+		if(version == null) {
+			version = new Long(1);
+			LOG.info("Found Version Value: `null`, so setting value of version to 1, While updating object, version should not be null.");
+		} else {
+			version = new Long(version.longValue() + 1);
+		}
 		
+		service.setVersion(version);
 		service = svcService.update(service);
 		XXService xUpdService = daoMgr.getXXService().getById(service.getId());
 		
@@ -573,7 +606,17 @@ public class ServiceDBStore implements ServiceStore {
 			configDao.remove(configMap);
 		}
 		
+		Long version = service.getVersion();
+		if(version == null) {
+			version = new Long(1);
+			LOG.info("Found Version Value: `null`, so setting value of version to 1, While updating object, version should not be null.");
+		} else {
+			version = new Long(version.longValue() + 1);
+		}
+		service.setVersion(version);
+		
 		svcService.delete(service);
+		
 		dataHistService.createObjectDataHistory(service, RangerDataHistService.ACTION_DELETE);
 		
 		List<XXTrxLog> trxLogList = svcService.getTransactionLog(service, RangerServiceService.OPERATION_DELETE_CONTEXT);
@@ -602,11 +645,24 @@ public class ServiceDBStore implements ServiceStore {
 		if(LOG.isDebugEnabled()) {
 			LOG.debug("==> ServiceDBStore.getServices()");
 		}
-		List<RangerService> ret = svcService.searchRangerPolicies(filter);
+		RangerServiceList serviceList = svcService.searchRangerServices(filter);
+		List<RangerService> ret = serviceList.getServices();
 
 		return ret;
 	}
 
+	public RangerServiceList getPaginatedServices(SearchFilter filter) throws Exception {
+		if (LOG.isDebugEnabled()) {
+			LOG.debug("==> ServiceDBStore.getPaginatedServices()");
+		}
+		RangerServiceList serviceList = svcService.searchRangerServices(filter);
+
+		if (LOG.isDebugEnabled()) {
+			LOG.debug("<== ServiceDBStore.getPaginatedServices()");
+		}
+		return serviceList;
+	}
+
 	@Override
 	public RangerPolicy createPolicy(RangerPolicy policy) throws Exception {
 
@@ -631,6 +687,8 @@ public class ServiceDBStore implements ServiceStore {
 		Map<String, RangerPolicyResource> resources = policy.getResources();
 		List<RangerPolicyItem> policyItems = policy.getPolicyItems();
 
+		policy.setVersion(new Long(1));
+		
 		if(populateExistingBaseFields) {
 			policyService.setPopulateExistingBaseFields(true);
 			policy = policyService.create(policy);
@@ -696,6 +754,16 @@ public class ServiceDBStore implements ServiceStore {
 		
 		List<XXTrxLog> trxLogList = policyService.getTransactionLog(policy, xxExisting, RangerPolicyService.OPERATION_UPDATE_CONTEXT);
 		
+		Long version = policy.getVersion();
+		if(version == null) {
+			version = new Long(1);
+			LOG.info("Found Version Value: `null`, so setting value of version to 1, While updating object, version should not be null.");
+		} else {
+			version = new Long(version.longValue() + 1);
+		}
+		
+		policy.setVersion(version);
+		
 		policy = policyService.update(policy);
 		XXPolicy newUpdPolicy = daoMgr.getXXPolicy().getById(policy.getId());
 
@@ -733,6 +801,16 @@ public class ServiceDBStore implements ServiceStore {
 			throw new Exception("service does not exist - name='" + policy.getService());
 		}
 		
+		Long version = policy.getVersion();
+		if(version == null) {
+			version = new Long(1);
+			LOG.info("Found Version Value: `null`, so setting value of version to 1, While updating object, version should not be null.");
+		} else {
+			version = new Long(version.longValue() + 1);
+		}
+		
+		policy.setVersion(version);
+		
 		List<XXTrxLog> trxLogList = policyService.getTransactionLog(policy, RangerPolicyService.OPERATION_DELETE_CONTEXT);
 		
 		deleteExistingPolicyItems(policy);
@@ -759,11 +837,30 @@ public class ServiceDBStore implements ServiceStore {
 			LOG.debug("==> ServiceDBStore.getPolicies()");
 		}
 
-		List<RangerPolicy> ret = policyService.searchRangerPolicies(filter);
+		RangerPolicyList policyList = policyService.searchRangerPolicies(filter);
+		List<RangerPolicy> ret = policyList.getPolicies();
 
+		if(LOG.isDebugEnabled()) {
+			LOG.debug("<== ServiceDBStore.getPolicies()");
+		}
+		
 		return ret;
 	}
 
+	public RangerPolicyList getPaginatedPolicies(SearchFilter filter) throws Exception {
+		if (LOG.isDebugEnabled()) {
+			LOG.debug("==> ServiceDBStore.getPaginatedPolicies()");
+		}
+
+		RangerPolicyList policyList = policyService.searchRangerPolicies(filter);
+
+		if (LOG.isDebugEnabled()) {
+			LOG.debug("<== ServiceDBStore.getPaginatedPolicies()");
+		}
+
+		return policyList;
+	}
+
 	@Override
 	public List<RangerPolicy> getServicePolicies(Long serviceId, SearchFilter filter) throws Exception {
 		if(LOG.isDebugEnabled()) {
@@ -781,6 +878,25 @@ public class ServiceDBStore implements ServiceStore {
 		return ret;
 	}
 
+	public RangerPolicyList getPaginatedServicePolicies(Long serviceId, SearchFilter filter) throws Exception {
+		if (LOG.isDebugEnabled()) {
+			LOG.debug("==> ServiceDBStore.getPaginatedServicePolicies(" + serviceId + ")");
+		}
+
+		RangerService service = getService(serviceId);
+
+		if (service == null) {
+			throw new Exception("service does not exist - id='" + serviceId);
+		}
+
+		RangerPolicyList ret = getPaginatedServicePolicies(service.getName(), filter);
+
+		if (LOG.isDebugEnabled()) {
+			LOG.debug("<== ServiceDBStore.getPaginatedServicePolicies(" + serviceId + ")");
+		}
+		return ret;
+	}
+
 	@Override
 	public List<RangerPolicy> getServicePolicies(String serviceName, SearchFilter filter) throws Exception {
 		if(LOG.isDebugEnabled()) {
@@ -808,6 +924,33 @@ public class ServiceDBStore implements ServiceStore {
 		return ret;
 	}
 
+	public RangerPolicyList getPaginatedServicePolicies(String serviceName, SearchFilter filter) throws Exception {
+		if (LOG.isDebugEnabled()) {
+			LOG.debug("==> ServiceDBStore.getPaginatedServicePolicies(" + serviceName + ")");
+		}
+
+		RangerPolicyList ret = null;
+
+		try {
+			if (filter == null) {
+				filter = new SearchFilter();
+			}
+
+			filter.setParam(SearchFilter.SERVICE_NAME, serviceName);
+
+			ret = getPaginatedPolicies(filter);
+		} catch (Exception excp) {
+			LOG.error("ServiceDBStore.getPaginatedServicePolicies(" + serviceName + "): failed to read policies", excp);
+		}
+
+		if (LOG.isDebugEnabled()) {
+			LOG.debug("<== ServiceDBStore.getPaginatedServicePolicies(" + serviceName + "): count="
+					+ ((ret == null) ? 0 : ret.getListSize()));
+		}
+
+		return ret;
+	}
+
 	@Override
 	public ServicePolicies getServicePoliciesIfUpdated(String serviceName, Long lastKnownVersion) throws Exception {
 		if(LOG.isDebugEnabled()) {
@@ -870,7 +1013,7 @@ public class ServiceDBStore implements ServiceStore {
 			
 			String value;
 			if("path".equalsIgnoreCase(resDef.getName())) {
-				value = "/*/*";
+				value = "/*";
 			} else {
 				value = "*";
 			}
@@ -1151,4 +1294,14 @@ public class ServiceDBStore implements ServiceStore {
 		this.populateExistingBaseFields = populateExistingBaseFields;
 	}
 
-}
\ No newline at end of file
+	public RangerPolicy getPolicyFromEventTime(Date eventTime, Long policyId) {
+
+		XXDataHist xDataHist = daoMgr.getXXDataHist().findObjByEventTimeClassTypeAndId(eventTime,
+				AppConstants.CLASS_TYPE_RANGER_POLICY, policyId);
+		String content = xDataHist.getContent();
+		RangerPolicy policy = (RangerPolicy) dataHistService.writeJsonToJavaObject(content, RangerPolicy.class);
+
+		return policy;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/85d5658f/security-admin/src/main/java/org/apache/ranger/common/RangerSearchUtil.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/common/RangerSearchUtil.java b/security-admin/src/main/java/org/apache/ranger/common/RangerSearchUtil.java
index 192734e..205f4f5 100644
--- a/security-admin/src/main/java/org/apache/ranger/common/RangerSearchUtil.java
+++ b/security-admin/src/main/java/org/apache/ranger/common/RangerSearchUtil.java
@@ -21,11 +21,17 @@
 
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import javax.persistence.EntityManager;
 import javax.persistence.Query;
+import javax.servlet.http.HttpServletRequest;
 
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 import org.apache.ranger.plugin.util.SearchFilter;
 import org.springframework.stereotype.Component;
@@ -33,6 +39,86 @@ import org.springframework.stereotype.Component;
 @Component
 public class RangerSearchUtil extends SearchUtil {
 	final static Logger logger = Logger.getLogger(RangerSearchUtil.class);
+	
+	public SearchFilter getSearchFilter(HttpServletRequest request, List<SortField> sortFields) {
+		if (request == null) {
+			return null;
+		}
+
+		SearchFilter ret = new SearchFilter();
+
+		if (MapUtils.isEmpty(request.getParameterMap())) {
+			ret.setParams(new HashMap<String, String>());
+		}
+
+		ret.setParam(SearchFilter.LOGIN_USER, request.getParameter(SearchFilter.LOGIN_USER));
+		ret.setParam(SearchFilter.SERVICE_TYPE, request.getParameter(SearchFilter.SERVICE_TYPE));
+		ret.setParam(SearchFilter.SERVICE_TYPE_ID, request.getParameter(SearchFilter.SERVICE_TYPE_ID));
+		ret.setParam(SearchFilter.SERVICE_NAME, request.getParameter(SearchFilter.SERVICE_NAME));
+		ret.setParam(SearchFilter.SERVICE_ID, request.getParameter(SearchFilter.SERVICE_ID));
+		ret.setParam(SearchFilter.POLICY_NAME, request.getParameter(SearchFilter.POLICY_NAME));
+		ret.setParam(SearchFilter.POLICY_NAME_PARTIAL, request.getParameter(SearchFilter.POLICY_NAME_PARTIAL));
+		ret.setParam(SearchFilter.POLICY_ID, request.getParameter(SearchFilter.POLICY_ID));
+		ret.setParam(SearchFilter.STATUS, request.getParameter(SearchFilter.STATUS));
+		ret.setParam(SearchFilter.USER, request.getParameter(SearchFilter.USER));
+		ret.setParam(SearchFilter.GROUP, request.getParameter(SearchFilter.GROUP));
+		ret.setParam(SearchFilter.POL_RESOURCE, request.getParameter(SearchFilter.POL_RESOURCE));
+
+		for (Map.Entry<String, String[]> e : request.getParameterMap().entrySet()) {
+			String name = e.getKey();
+			String[] values = e.getValue();
+
+			if (!StringUtils.isEmpty(name) && !ArrayUtils.isEmpty(values)
+					&& name.startsWith(SearchFilter.RESOURCE_PREFIX)) {
+				ret.setParam(name, values[0]);
+			}
+		}
+		
+		extractCommonCriteriasForFilter(request, ret, sortFields);
+
+		return ret;
+	}
+
+	public SearchFilter extractCommonCriteriasForFilter(HttpServletRequest request, SearchFilter ret, List<SortField> sortFields) {
+		int startIndex = restErrorUtil.parseInt(request.getParameter(SearchFilter.START_INDEX), 0,
+				"Invalid value for parameter startIndex", MessageEnums.INVALID_INPUT_DATA, null,
+				SearchFilter.START_INDEX);
+		ret.setStartIndex(startIndex);
+
+		int pageSize = restErrorUtil.parseInt(request.getParameter(SearchFilter.PAGE_SIZE),
+				configUtil.getDefaultMaxRows(), "Invalid value for parameter pageSize",
+				MessageEnums.INVALID_INPUT_DATA, null, SearchFilter.PAGE_SIZE);
+		ret.setMaxRows(pageSize);
+
+		ret.setGetCount(restErrorUtil.parseBoolean(request.getParameter("getCount"), true));
+		String sortBy = restErrorUtil.validateString(request.getParameter(SearchFilter.SORT_BY),
+				StringUtil.VALIDATION_ALPHA, "Invalid value for parameter sortBy", MessageEnums.INVALID_INPUT_DATA,
+				null, SearchFilter.SORT_BY);
+
+		boolean sortSet = false;
+		if (!StringUtils.isEmpty(sortBy)) {
+			for (SortField sortField : sortFields) {
+				if (sortField.getParamName().equalsIgnoreCase(sortBy)) {
+					ret.setSortBy(sortField.getParamName());
+					String sortType = restErrorUtil.validateString(request.getParameter("sortType"),
+							StringUtil.VALIDATION_ALPHA, "Invalid value for parameter sortType",
+							MessageEnums.INVALID_INPUT_DATA, null, "sortType");
+					ret.setSortType(sortType);
+					sortSet = true;
+					break;
+				}
+			}
+		}
+
+		if (!sortSet && !StringUtils.isEmpty(sortBy)) {
+			logger.info("Invalid or unsupported sortBy field passed. sortBy=" + sortBy, new Throwable());
+		}
+		
+		if(ret.getParams() == null) {
+			ret.setParams(new HashMap<String, String>());
+		}
+		return ret;
+	}
 
 	public Query createSearchQuery(EntityManager em, String queryStr, String sortClause,
 			SearchFilter searchCriteria, List<SearchField> searchFields,

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/85d5658f/security-admin/src/main/java/org/apache/ranger/db/XXDataHistDao.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXDataHistDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXDataHistDao.java
index 29c4246..4479145 100644
--- a/security-admin/src/main/java/org/apache/ranger/db/XXDataHistDao.java
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXDataHistDao.java
@@ -1,6 +1,9 @@
 package org.apache.ranger.db;
 
+import java.util.Date;
+
 import javax.persistence.NoResultException;
+import javax.persistence.Query;
 
 import org.apache.ranger.common.db.BaseDao;
 import org.apache.ranger.entity.XXDataHist;
@@ -25,5 +28,20 @@ public class XXDataHistDao extends BaseDao<XXDataHist> {
 			return null;
 		}
 	}
+	
+	public XXDataHist findObjByEventTimeClassTypeAndId(Date eventTime, int classType, Long objId) {
+		if (eventTime == null || objId == null) {
+			return null;
+		}
+		try {
+			String queryStr = "select obj.* from x_data_hist obj where obj.obj_class_type = "+classType
+					+ " and obj.obj_id = "+objId + " and obj.create_time <= '" + eventTime + "' ORDER BY obj.id DESC";
+			Query jpaQuery = getEntityManager().createNativeQuery(queryStr, tClass).setMaxResults(1);
+			
+			return (XXDataHist) jpaQuery.getSingleResult();
+		} catch (NoResultException e) {
+			return null;
+		}
+	}
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/85d5658f/security-admin/src/main/java/org/apache/ranger/rest/ServiceREST.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/rest/ServiceREST.java b/security-admin/src/main/java/org/apache/ranger/rest/ServiceREST.java
index ec64e89..1cfaa91 100644
--- a/security-admin/src/main/java/org/apache/ranger/rest/ServiceREST.java
+++ b/security-admin/src/main/java/org/apache/ranger/rest/ServiceREST.java
@@ -21,6 +21,7 @@ package org.apache.ranger.rest;
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -40,8 +41,6 @@ import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Context;
 
 import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.MapUtils;
-import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -49,7 +48,10 @@ import org.apache.ranger.admin.client.datatype.RESTResponse;
 import org.apache.ranger.biz.AssetMgr;
 import org.apache.ranger.biz.ServiceDBStore;
 import org.apache.ranger.biz.ServiceMgr;
+import org.apache.ranger.common.MessageEnums;
 import org.apache.ranger.common.RESTErrorUtil;
+import org.apache.ranger.common.RangerConfigUtil;
+import org.apache.ranger.common.RangerSearchUtil;
 import org.apache.ranger.common.ServiceUtil;
 import org.apache.ranger.entity.XXPolicyExportAudit;
 import org.apache.ranger.plugin.model.RangerPolicy;
@@ -72,6 +74,12 @@ import org.apache.ranger.plugin.service.ResourceLookupContext;
 import org.apache.ranger.plugin.util.GrantRevokeRequest;
 import org.apache.ranger.plugin.util.SearchFilter;
 import org.apache.ranger.plugin.util.ServicePolicies;
+import org.apache.ranger.service.RangerPolicyService;
+import org.apache.ranger.service.RangerServiceDefService;
+import org.apache.ranger.service.RangerServiceService;
+import org.apache.ranger.view.RangerPolicyList;
+import org.apache.ranger.view.RangerServiceDefList;
+import org.apache.ranger.view.RangerServiceList;
 import org.apache.ranger.view.VXResponse;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Scope;
@@ -103,6 +111,21 @@ public class ServiceREST {
 	@Autowired
 	ServiceUtil serviceUtil;
 	
+	@Autowired
+	RangerConfigUtil configUtil;
+	
+	@Autowired
+	RangerPolicyService policyService;
+	
+	@Autowired
+	RangerServiceService svcService;
+	
+	@Autowired
+	RangerServiceDefService serviceDefService;
+	
+	@Autowired
+	RangerSearchUtil searchUtil;
+	
 	// this indirection for validation via a factory exists only for testability
 	// TODO move the instantiation to DI framework?
 	RangerValidatorFactory validatorFactory = new RangerValidatorFactory(); 
@@ -250,7 +273,7 @@ public class ServiceREST {
 	}
 
 	@GET
-	@Path("/definitions")
+	@Path("/definitions/unpaginated")
 	@Produces({ "application/json", "application/xml" })
 	public List<RangerServiceDef> getServiceDefs(@Context HttpServletRequest request) {
 		if(LOG.isDebugEnabled()) {
@@ -259,7 +282,7 @@ public class ServiceREST {
 
 		List<RangerServiceDef> ret = null;
 
-		SearchFilter filter = getSearchFilter(request);
+		SearchFilter filter = searchUtil.getSearchFilter(request, serviceDefService.sortFields);
 
 		try {
 			ret = svcStore.getServiceDefs(filter);
@@ -417,7 +440,7 @@ public class ServiceREST {
 	}
 
 	@GET
-	@Path("/services")
+	@Path("/services/unpaginated")
 	@Produces({ "application/json", "application/xml" })
 	public List<RangerService> getServices(@Context HttpServletRequest request) {
 		if(LOG.isDebugEnabled()) {
@@ -426,7 +449,7 @@ public class ServiceREST {
 
 		List<RangerService> ret = null;
 
-		SearchFilter filter = getSearchFilter(request);
+		SearchFilter filter = searchUtil.getSearchFilter(request, svcService.sortFields);
 
 		try {
 			ret = svcStore.getServices(filter);
@@ -899,7 +922,7 @@ public class ServiceREST {
 	}
 
 	@GET
-	@Path("/policies")
+	@Path("/policies/unpaginated")
 	@Produces({ "application/json", "application/xml" })
 	public List<RangerPolicy> getPolicies(@Context HttpServletRequest request) {
 		if(LOG.isDebugEnabled()) {
@@ -908,7 +931,8 @@ public class ServiceREST {
 
 		List<RangerPolicy> ret = null;
 
-		SearchFilter filter = getSearchFilter(request);
+		SearchFilter filter = searchUtil.getSearchFilter(request, policyService.sortFields);
+		
 
 		try {
 			ret = svcStore.getPolicies(filter);
@@ -953,7 +977,7 @@ public class ServiceREST {
 	}
 
 	@GET
-	@Path("/policies/service/{id}")
+	@Path("/policies/service/unpaginated/{id}")
 	@Produces({ "application/json", "application/xml" })
 	public List<RangerPolicy> getServicePolicies(@PathParam("id") Long serviceId, @Context HttpServletRequest request) {
 		if(LOG.isDebugEnabled()) {
@@ -962,7 +986,7 @@ public class ServiceREST {
 
 		List<RangerPolicy> ret = null;
 
-		SearchFilter filter = getSearchFilter(request);
+		SearchFilter filter = searchUtil.getSearchFilter(request, policyService.sortFields);
 
 		try {
 			ret = svcStore.getServicePolicies(serviceId, filter);
@@ -984,7 +1008,7 @@ public class ServiceREST {
 	}
 
 	@GET
-	@Path("/policies/service/name/{name}")
+	@Path("/policies/service/unpaginated/name/{name}")
 	@Produces({ "application/json", "application/xml" })
 	public List<RangerPolicy> getServicePolicies(@PathParam("name") String serviceName, @Context HttpServletRequest request) {
 		if(LOG.isDebugEnabled()) {
@@ -993,7 +1017,7 @@ public class ServiceREST {
 
 		List<RangerPolicy> ret = null;
 
-		SearchFilter filter = getSearchFilter(request);
+		SearchFilter filter = searchUtil.getSearchFilter(request, policyService.sortFields);
 
 		try {
 			ret = svcStore.getServicePolicies(serviceName, filter);
@@ -1060,44 +1084,6 @@ public class ServiceREST {
 		return ret;
 	}
 
-
-	private SearchFilter getSearchFilter(HttpServletRequest request) {
-		if(request == null) {
-			return null;
-		}
-		
-		SearchFilter ret = new SearchFilter();
-
-		if(MapUtils.isEmpty(request.getParameterMap())) {
-			ret.setParams(new HashMap<String, String>());
-		}
-
-		ret.setParam(SearchFilter.LOGIN_USER, request.getParameter(SearchFilter.LOGIN_USER));
-		ret.setParam(SearchFilter.SERVICE_TYPE, request.getParameter(SearchFilter.SERVICE_TYPE));
-		ret.setParam(SearchFilter.SERVICE_TYPE_ID, request.getParameter(SearchFilter.SERVICE_TYPE_ID));
-		ret.setParam(SearchFilter.SERVICE_NAME, request.getParameter(SearchFilter.SERVICE_NAME));
-		ret.setParam(SearchFilter.SERVICE_ID, request.getParameter(SearchFilter.SERVICE_ID));
-		ret.setParam(SearchFilter.POLICY_NAME, request.getParameter(SearchFilter.POLICY_NAME));
-		ret.setParam(SearchFilter.POLICY_ID, request.getParameter(SearchFilter.POLICY_ID));
-		ret.setParam(SearchFilter.STATUS, request.getParameter(SearchFilter.STATUS));
-		ret.setParam(SearchFilter.USER, request.getParameter(SearchFilter.USER));
-		ret.setParam(SearchFilter.GROUP, request.getParameter(SearchFilter.GROUP));
-		ret.setParam(SearchFilter.SORT_BY, request.getParameter(SearchFilter.SORT_BY));
-		ret.setParam(SearchFilter.START_INDEX, request.getParameter(SearchFilter.START_INDEX));
-		ret.setParam(SearchFilter.PAGE_SIZE, request.getParameter(SearchFilter.PAGE_SIZE));
-		
-		for(Map.Entry<String, String[]> e : request.getParameterMap().entrySet()) {
-			String   name   = e.getKey();
-			String[] values = e.getValue();
-			
-			if(!StringUtils.isEmpty(name) && !ArrayUtils.isEmpty(values) && name.startsWith(SearchFilter.RESOURCE_PREFIX)) {
-				ret.setParam(name, values[0]);
-			}
-		}
-
-		return ret;
-	}
-
 	private void createPolicyDownloadAudit(String serviceName, Long lastKnownVersion, String pluginId, ServicePolicies policies, int httpRespCode, HttpServletRequest request) {
 		try {
 			String ipAddress = request.getHeader("X-FORWARDED-FOR");
@@ -1347,4 +1333,178 @@ public class ServiceREST {
 
 		return ret;
 	}
+
+	@GET
+	@Path("/definitions")
+	@Produces({ "application/json", "application/xml" })
+	public RangerServiceDefList getPaginatedServiceDefs(@Context HttpServletRequest request) {
+		if (LOG.isDebugEnabled()) {
+			LOG.debug("==> ServiceREST.getPaginatedServiceDefs()");
+		}
+
+		RangerServiceDefList ret = null;
+
+		SearchFilter filter = searchUtil.getSearchFilter(request, serviceDefService.sortFields);
+
+		try {
+			ret = svcStore.getPaginatedServiceDefs(filter);
+		} catch (Exception excp) {
+			LOG.error("getServiceDefs() failed", excp);
+
+			throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, excp.getMessage(), true);
+		}
+
+		if (LOG.isDebugEnabled()) {
+			LOG.debug("<== ServiceREST.getPaginatedServiceDefs(): count=" + (ret == null ? 0 : ret.getListSize()));
+		}
+		return ret;
+	}
+
+	@GET
+	@Path("/services")
+	@Produces({ "application/json", "application/xml" })
+	public RangerServiceList getPaginatedServices(@Context HttpServletRequest request) {
+		if (LOG.isDebugEnabled()) {
+			LOG.debug("==> ServiceREST.getPaginatedServices()");
+		}
+
+		RangerServiceList ret = null;
+
+		SearchFilter filter = searchUtil.getSearchFilter(request, svcService.sortFields);
+
+		try {
+			ret = svcStore.getPaginatedServices(filter);
+		} catch (Exception excp) {
+			LOG.error("getServices() failed", excp);
+
+			throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, excp.getMessage(), true);
+		}
+
+		if (LOG.isDebugEnabled()) {
+			LOG.debug("<== ServiceREST.getPaginatedServices(): count=" + (ret == null ? 0 : ret.getListSize()));
+		}
+		return ret;
+	}
+
+	@GET
+	@Path("/policies")
+	@Produces({ "application/json", "application/xml" })
+	public RangerPolicyList getPaginatedPolicies(@Context HttpServletRequest request) {
+		if (LOG.isDebugEnabled()) {
+			LOG.debug("==> ServiceREST.getPaginatedPolicies()");
+		}
+
+		RangerPolicyList ret = null;
+
+		SearchFilter filter = searchUtil.getSearchFilter(request, policyService.sortFields);
+
+		try {
+			ret = svcStore.getPaginatedPolicies(filter);
+		} catch (Exception excp) {
+			LOG.error("getPolicies() failed", excp);
+
+			throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, excp.getMessage(), true);
+		}
+
+		if (LOG.isDebugEnabled()) {
+			LOG.debug("<== ServiceREST.getPaginatedPolicies(): count=" + (ret == null ? 0 : ret.getListSize()));
+		}
+		return ret;
+	}
+
+	@GET
+	@Path("/policies/service/{id}")
+	@Produces({ "application/json", "application/xml" })
+	public RangerPolicyList getPaginatedServicePolicies(@PathParam("id") Long serviceId,
+			@Context HttpServletRequest request) {
+		if (LOG.isDebugEnabled()) {
+			LOG.debug("==> ServiceREST.getServicePolicies(" + serviceId + ")");
+		}
+
+		RangerPolicyList ret = null;
+
+		SearchFilter filter = searchUtil.getSearchFilter(request, policyService.sortFields);
+
+		try {
+			ret = svcStore.getPaginatedServicePolicies(serviceId, filter);
+		} catch (Exception excp) {
+			LOG.error("getServicePolicies(" + serviceId + ") failed", excp);
+
+			throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, excp.getMessage(), true);
+		}
+
+		if (ret == null) {
+			throw restErrorUtil.createRESTException(HttpServletResponse.SC_NOT_FOUND, "Not found", true);
+		}
+
+		if (LOG.isDebugEnabled()) {
+			LOG.debug("<== ServiceREST.getServicePolicies(" + serviceId + "): count="
+					+ (ret == null ? 0 : ret.getListSize()));
+		}
+		return ret;
+	}
+
+	@GET
+	@Path("/policies/service/name/{name}")
+	@Produces({ "application/json", "application/xml" })
+	public RangerPolicyList getPaginatedServicePolicies(@PathParam("name") String serviceName,
+			@Context HttpServletRequest request) {
+		if (LOG.isDebugEnabled()) {
+			LOG.debug("==> ServiceREST.getServicePolicies(" + serviceName + ")");
+		}
+
+		RangerPolicyList ret = null;
+
+		SearchFilter filter = searchUtil.getSearchFilter(request, policyService.sortFields);
+
+		try {
+			ret = svcStore.getPaginatedServicePolicies(serviceName, filter);
+		} catch (Exception excp) {
+			LOG.error("getServicePolicies(" + serviceName + ") failed", excp);
+
+			throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, excp.getMessage(), true);
+		}
+
+		if (ret == null) {
+			throw restErrorUtil.createRESTException(HttpServletResponse.SC_NOT_FOUND, "Not found", true);
+		}
+
+		if (LOG.isDebugEnabled()) {
+			LOG.debug("<== ServiceREST.getServicePolicies(" + serviceName + "): count="
+					+ (ret == null ? 0 : ret.getListSize()));
+		}
+
+		return ret;
+	}
+
+	@GET
+	@Path("/policies/eventTime")
+	@Produces({ "application/json", "application/xml" })
+	public RangerPolicy getPolicyFromEventTime(@Context HttpServletRequest request) {
+		if (LOG.isDebugEnabled()) {
+			LOG.debug("==> ServiceREST.getPolicyFromEventTime()");
+		}
+
+		String eventTimeStr = request.getParameter("eventTime");
+		String policyIdStr = request.getParameter("policyId");
+
+		if (StringUtils.isEmpty(eventTimeStr) || StringUtils.isEmpty(policyIdStr)) {
+			throw restErrorUtil.createRESTException("EventTime or policyId cannot be null or empty string.",
+					MessageEnums.INVALID_INPUT_DATA);
+		}
+
+		Long policyId = Long.parseLong(policyIdStr);
+
+		Date eventTime = restErrorUtil.parseDate(eventTimeStr, "Invalid value for" + "Event Time",
+				MessageEnums.INVALID_INPUT_DATA, null, "eventTime", "MM/dd/yyyy");
+
+		RangerPolicy policy = svcStore.getPolicyFromEventTime(eventTime, policyId);
+
+		if (LOG.isDebugEnabled()) {
+			LOG.debug("<== ServiceREST.getPolicyFromEventTime()");
+		}
+
+		return policy;
+	}
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/85d5658f/security-admin/src/main/java/org/apache/ranger/service/RangerDataHistService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/service/RangerDataHistService.java b/security-admin/src/main/java/org/apache/ranger/service/RangerDataHistService.java
index a5aa16e..b75b514 100644
--- a/security-admin/src/main/java/org/apache/ranger/service/RangerDataHistService.java
+++ b/security-admin/src/main/java/org/apache/ranger/service/RangerDataHistService.java
@@ -122,5 +122,22 @@ public class RangerDataHistService {
 					MessageEnums.INVALID_INPUT_DATA);
 		}
 	}
-	
+
+	public Object writeJsonToJavaObject(String json, Class<?> tClass) {
+		ObjectMapper mapper = new ObjectMapper();
+
+		try {
+			return mapper.readValue(json, tClass);
+		} catch (JsonParseException e) {
+			throw restErrorUtil.createRESTException("Invalid input data: " + e.getMessage(),
+					MessageEnums.INVALID_INPUT_DATA);
+		} catch (JsonMappingException e) {
+			throw restErrorUtil.createRESTException("Invalid input data: " + e.getMessage(),
+					MessageEnums.INVALID_INPUT_DATA);
+		} catch (IOException e) {
+			throw restErrorUtil.createRESTException("Invalid input data: " + e.getMessage(),
+					MessageEnums.INVALID_INPUT_DATA);
+		}
+	}
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/85d5658f/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyService.java b/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyService.java
index ace800d..1db4779 100644
--- a/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyService.java
+++ b/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyService.java
@@ -88,6 +88,10 @@ public class RangerPolicyService extends RangerPolicyServiceBase<XXPolicy, Range
 		searchFields.add(new SearchField(SearchFilter.GROUP, "xGrp.name", DATA_TYPE.STRING, SEARCH_TYPE.FULL, 
 				"XXGroup xGrp, XXPolicyItem xPolItem, XXPolicyItemGroupPerm grpPerm", "obj.id = xPolItem.policyId "
 						+ "and grpPerm.policyItemId = xPolItem.id and xGrp.id = grpPerm.groupId"));
+		searchFields.add(new SearchField(SearchFilter.POL_RESOURCE, "resMap.value", DATA_TYPE.STRING,
+				SEARCH_TYPE.PARTIAL, "XXPolicyResourceMap resMap, XXPolicyResource polRes",
+				"resMap.resourceId = polRes.id and polRes.policyId = obj.id"));
+		searchFields.add(new SearchField(SearchFilter.POLICY_NAME_PARTIAL, "obj.name", DATA_TYPE.STRING, SEARCH_TYPE.PARTIAL));
 		
 		sortFields.add(new SortField(SearchFilter.CREATE_TIME, "obj.createTime"));
 		sortFields.add(new SortField(SearchFilter.UPDATE_TIME, "obj.updateTime"));

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/85d5658f/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyServiceBase.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyServiceBase.java b/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyServiceBase.java
index d19e580..58c2b69 100644
--- a/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyServiceBase.java
+++ b/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyServiceBase.java
@@ -8,10 +8,9 @@ import org.apache.ranger.common.GUIDUtil;
 import org.apache.ranger.common.MessageEnums;
 import org.apache.ranger.entity.XXPolicy;
 import org.apache.ranger.entity.XXService;
-import org.apache.ranger.entity.XXServiceDef;
 import org.apache.ranger.plugin.model.RangerPolicy;
-import org.apache.ranger.plugin.model.RangerServiceDef;
 import org.apache.ranger.plugin.util.SearchFilter;
+import org.apache.ranger.view.RangerPolicyList;
 
 public abstract class RangerPolicyServiceBase<T extends XXPolicy, V extends RangerPolicy> extends RangerBaseModelService<T, V> {
 	
@@ -52,17 +51,19 @@ public abstract class RangerPolicyServiceBase<T extends XXPolicy, V extends Rang
 		vObj.setIsAuditEnabled(xObj.getIsAuditEnabled());
 		return vObj;
 	}
-	
+
 	@SuppressWarnings("unchecked")
-	public List<RangerPolicy> searchRangerPolicies(SearchFilter searchFilter) {
+	public RangerPolicyList searchRangerPolicies(SearchFilter searchFilter) {
 		List<RangerPolicy> policyList = new ArrayList<RangerPolicy>();
+		RangerPolicyList retList = new RangerPolicyList();
 		
-		List<XXPolicy> xPolList = (List<XXPolicy>) searchResources(searchFilter, searchFields, sortFields, null);
-		for(XXPolicy xPol : xPolList) {
+		List<XXPolicy> xPolList = (List<XXPolicy>) searchResources(searchFilter, searchFields, sortFields, retList);
+		for (XXPolicy xPol : xPolList) {
 			policyList.add(populateViewBean((T) xPol));
 		}
-		
-		return policyList;
+		retList.setPolicies(policyList);
+
+		return retList;
 	}
-	
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/85d5658f/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 374217f..afaf2cb 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
@@ -27,6 +27,7 @@ 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.beans.factory.annotation.Autowired;
 
 public abstract class RangerServiceDefServiceBase<T extends XXServiceDef, V extends RangerServiceDef>
@@ -302,17 +303,20 @@ public abstract class RangerServiceDefServiceBase<T extends XXServiceDef, V exte
 		vObj.setRbKeyLabel(xObj.getRbkeylabel());
 		return vObj;
 	}
-	
+
 	@SuppressWarnings("unchecked")
-	public List<RangerServiceDef> searchRangerServiceDefs(SearchFilter searchFilter) {
+	public RangerServiceDefList searchRangerServiceDefs(SearchFilter searchFilter) {
 		List<RangerServiceDef> serviceDefList = new ArrayList<RangerServiceDef>();
-		
-		List<XXServiceDef> xSvcDefList = (List<XXServiceDef>) searchResources(searchFilter, searchFields, sortFields, null);
-		for(XXServiceDef xSvcDef : xSvcDefList) {
+		RangerServiceDefList retList = new RangerServiceDefList();
+
+		List<XXServiceDef> xSvcDefList = (List<XXServiceDef>) searchResources(searchFilter, searchFields, sortFields, retList);
+		for (XXServiceDef xSvcDef : xSvcDefList) {
 			serviceDefList.add(populateViewBean((T) xSvcDef));
 		}
-		
-		return serviceDefList;
+
+		retList.setServiceDefs(serviceDefList);
+
+		return retList;
 	}
-	
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/85d5658f/security-admin/src/main/java/org/apache/ranger/service/RangerServiceServiceBase.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/service/RangerServiceServiceBase.java b/security-admin/src/main/java/org/apache/ranger/service/RangerServiceServiceBase.java
index 6f484ec..fb6142e 100644
--- a/security-admin/src/main/java/org/apache/ranger/service/RangerServiceServiceBase.java
+++ b/security-admin/src/main/java/org/apache/ranger/service/RangerServiceServiceBase.java
@@ -10,6 +10,7 @@ import org.apache.ranger.entity.XXService;
 import org.apache.ranger.entity.XXServiceDef;
 import org.apache.ranger.plugin.model.RangerService;
 import org.apache.ranger.plugin.util.SearchFilter;
+import org.apache.ranger.view.RangerServiceList;
 
 public abstract class RangerServiceServiceBase<T extends XXService, V extends RangerService> extends RangerBaseModelService<T, V> {
 	
@@ -49,17 +50,18 @@ public abstract class RangerServiceServiceBase<T extends XXService, V extends Ra
 		vObj.setPolicyUpdateTime(xObj.getPolicyUpdateTime());
 		return vObj;
 	}
-	
+
 	@SuppressWarnings("unchecked")
-	public List<RangerService> searchRangerPolicies(SearchFilter searchFilter) {
+	public RangerServiceList searchRangerServices(SearchFilter searchFilter) {
 		List<RangerService> serviceList = new ArrayList<RangerService>();
-		
-		List<XXService> xSvcList = (List<XXService>) searchResources(searchFilter, searchFields, sortFields, null);
-		for(XXService xSvc : xSvcList) {
+		RangerServiceList retList = new RangerServiceList();
+
+		List<XXService> xSvcList = (List<XXService>) searchResources(searchFilter, searchFields, sortFields, retList);
+		for (XXService xSvc : xSvcList) {
 			serviceList.add(populateViewBean((T) xSvc));
 		}
-		
-		return serviceList;
+		retList.setServices(serviceList);
+		return retList;
 	}
-	
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/85d5658f/security-admin/src/main/java/org/apache/ranger/view/RangerPolicyList.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/view/RangerPolicyList.java b/security-admin/src/main/java/org/apache/ranger/view/RangerPolicyList.java
new file mode 100644
index 0000000..d4f8b2f
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/view/RangerPolicyList.java
@@ -0,0 +1,55 @@
+package org.apache.ranger.view;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.ranger.common.view.VList;
+import org.apache.ranger.plugin.model.RangerPolicy;
+import org.codehaus.jackson.annotate.JsonAutoDetect;
+import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+@JsonAutoDetect(getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, fieldVisibility = Visibility.ANY)
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+public class RangerPolicyList extends VList {
+	private static final long serialVersionUID = 1L;
+
+	List<RangerPolicy> policies = new ArrayList<RangerPolicy>();
+
+	public RangerPolicyList() {
+		super();
+	}
+
+	public RangerPolicyList(List<RangerPolicy> objList) {
+		super(objList);
+		this.policies = objList;
+	}
+
+	public List<RangerPolicy> getPolicies() {
+		return policies;
+	}
+
+	public void setPolicies(List<RangerPolicy> policies) {
+		this.policies = policies;
+	}
+
+	@Override
+	public int getListSize() {
+		if (policies != null) {
+			return policies.size();
+		}
+		return 0;
+	}
+
+	@Override
+	public List<?> getList() {
+		return policies;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/85d5658f/security-admin/src/main/java/org/apache/ranger/view/RangerServiceDefList.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/view/RangerServiceDefList.java b/security-admin/src/main/java/org/apache/ranger/view/RangerServiceDefList.java
new file mode 100644
index 0000000..eba8e9c
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/view/RangerServiceDefList.java
@@ -0,0 +1,55 @@
+package org.apache.ranger.view;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.ranger.common.view.VList;
+import org.apache.ranger.plugin.model.RangerServiceDef;
+import org.codehaus.jackson.annotate.JsonAutoDetect;
+import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+@JsonAutoDetect(getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, fieldVisibility = Visibility.ANY)
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+public class RangerServiceDefList extends VList {
+	private static final long serialVersionUID = 1L;
+
+	List<RangerServiceDef> serviceDefs = new ArrayList<RangerServiceDef>();
+
+	public RangerServiceDefList() {
+		super();
+	}
+
+	public RangerServiceDefList(List<RangerServiceDef> objList) {
+		super(objList);
+		this.serviceDefs = objList;
+	}
+
+	public List<RangerServiceDef> getServiceDefs() {
+		return serviceDefs;
+	}
+
+	public void setServiceDefs(List<RangerServiceDef> serviceDefs) {
+		this.serviceDefs = serviceDefs;
+	}
+
+	@Override
+	public int getListSize() {
+		if (serviceDefs != null) {
+			return serviceDefs.size();
+		}
+		return 0;
+	}
+
+	@Override
+	public List<?> getList() {
+		return serviceDefs;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/85d5658f/security-admin/src/main/java/org/apache/ranger/view/RangerServiceList.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/view/RangerServiceList.java b/security-admin/src/main/java/org/apache/ranger/view/RangerServiceList.java
new file mode 100644
index 0000000..94780e5
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/view/RangerServiceList.java
@@ -0,0 +1,55 @@
+package org.apache.ranger.view;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.ranger.common.view.VList;
+import org.apache.ranger.plugin.model.RangerService;
+import org.codehaus.jackson.annotate.JsonAutoDetect;
+import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+@JsonAutoDetect(getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, fieldVisibility = Visibility.ANY)
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+public class RangerServiceList extends VList {
+	private static final long serialVersionUID = 1L;
+
+	List<RangerService> services = new ArrayList<RangerService>();
+
+	public RangerServiceList() {
+		super();
+	}
+
+	public RangerServiceList(List<RangerService> objList) {
+		super(objList);
+		this.services = objList;
+	}
+
+	public List<RangerService> getServices() {
+		return services;
+	}
+
+	public void setServices(List<RangerService> services) {
+		this.services = services;
+	}
+
+	@Override
+	public int getListSize() {
+		if (services != null) {
+			return services.size();
+		}
+		return 0;
+	}
+
+	@Override
+	public List<?> getList() {
+		return services;
+	}
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/85d5658f/security-admin/src/main/webapp/scripts/collection_bases/RangerPolicyListBase.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/collection_bases/RangerPolicyListBase.js b/security-admin/src/main/webapp/scripts/collection_bases/RangerPolicyListBase.js
index a63e4b2..f81f500 100644
--- a/security-admin/src/main/webapp/scripts/collection_bases/RangerPolicyListBase.js
+++ b/security-admin/src/main/webapp/scripts/collection_bases/RangerPolicyListBase.js
@@ -39,14 +39,8 @@ define(function(require){
 		 */
 		initialize : function() {
 			this.modelName = 'RangerPolicy';
-			this.modelAttrName = 'RangerPolicies';
+			this.modelAttrName = 'policies';
 			this.bindErrorEvents();
-		},
-			/**
-		 * override the parseRecords of PageableCollection for our use
-		 */
-		parseRecords : function(resp, options){
-			return resp;
 		}
 	},{
 		// static class members

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/85d5658f/security-admin/src/main/webapp/scripts/collection_bases/RangerServiceDefListBase.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/collection_bases/RangerServiceDefListBase.js b/security-admin/src/main/webapp/scripts/collection_bases/RangerServiceDefListBase.js
index 2754f62..9c57b61 100644
--- a/security-admin/src/main/webapp/scripts/collection_bases/RangerServiceDefListBase.js
+++ b/security-admin/src/main/webapp/scripts/collection_bases/RangerServiceDefListBase.js
@@ -39,15 +39,10 @@ define(function(require){
 		 */
 		initialize : function() {
 			this.modelName = 'RangerServiceDef';
-			this.modelAttrName = 'RangerServiceDefs';
+			this.modelAttrName = 'serviceDefs';
 			this.bindErrorEvents();
 		},
-			/**
-		 * override the parseRecords of PageableCollection for our use
-		 */
-		parseRecords : function(resp, options){
-			return resp;
-		},
+		
 		comparator: function(def) {
 	        return def.get('id');
 	    }

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/85d5658f/security-admin/src/main/webapp/scripts/collection_bases/RangerServiceListBase.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/collection_bases/RangerServiceListBase.js b/security-admin/src/main/webapp/scripts/collection_bases/RangerServiceListBase.js
index 99d1533..561d98f 100644
--- a/security-admin/src/main/webapp/scripts/collection_bases/RangerServiceListBase.js
+++ b/security-admin/src/main/webapp/scripts/collection_bases/RangerServiceListBase.js
@@ -39,15 +39,9 @@ define(function(require){
 		 */
 		initialize : function() {
 			this.modelName = 'RangerService';
-			this.modelAttrName = 'RangerServices';
+			this.modelAttrName = 'services';
 			this.bindErrorEvents();
 		},
-			/**
-		 * override the parseRecords of PageableCollection for our use
-		 */
-		parseRecords : function(resp, options){
-			return resp;
-		}
 	},{
 		// static class members
 		/**

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/85d5658f/security-admin/src/main/webapp/scripts/controllers/Controller.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/controllers/Controller.js b/security-admin/src/main/webapp/scripts/controllers/Controller.js
index 9915fb5..34a0a94 100644
--- a/security-admin/src/main/webapp/scripts/controllers/Controller.js
+++ b/security-admin/src/main/webapp/scripts/controllers/Controller.js
@@ -58,10 +58,10 @@ define(function(require) {
 	   userAccessReportAction : function(){
 		   MAppState.set({ 'currentTab' : XAGlobals.AppTabs.Analytics.value });
 		   var view				= require('views/reports/UserAccessLayout');
-		   var VXResourceList 	= require('collections/VXResourceList');
+		   var RangerPolicyList 	= require('collections/RangerPolicyList');
 		   var VXGroupList		= require('collections/VXGroupList');
 		   var VXUserList		= require('collections/VXUserList');
-		   var resourceList 	= new VXResourceList([],{
+		   var policyList 	= new RangerPolicyList([],{
 			   queryParams : {
 				   //'resourceType' : XAEnums.AssetType.ASSET_HDFS.value,
 				   //'assetId' : assetId 
@@ -70,29 +70,23 @@ define(function(require) {
 		   var that 		= this;
 		   this.groupList 	= new VXGroupList();
 		   this.userList 	= new VXUserList();
-		   resourceList.setPageSize(200, {fetch : false});
-		   resourceList.fetch({
-			   async:false,
-			   cache : false
-		   }).done(function(){
-				that.groupList.fetch({
-						async:false,
-						cache:false
-					}).done(function(){
-					that.userList.fetch({
-						async:false,
-						cache:false
-					}).done(function(){
-						if(App.rContent.currentView)
-							   App.rContent.currentView.close();
-						App.rContent.show(new view({
-							collection : resourceList,
-							groupList :that.groupList,
-							userList :that.userList
-						}));
-					});
+		   that.groupList.fetch({
+					async:false,
+					cache:false
+				}).done(function(){
+				that.userList.fetch({
+					async:false,
+					cache:false
+				}).done(function(){
+					if(App.rContent.currentView)
+						   App.rContent.currentView.close();
+					App.rContent.show(new view({
+						collection : policyList,
+						groupList :that.groupList,
+						userList :that.userList
+					}));
 				});
-		   });
+			});
 	   },
 	   auditReportAction : function(tab){
 		   MAppState.set({ 'currentTab' : XAGlobals.AppTabs.Audit.value });
@@ -230,7 +224,7 @@ define(function(require) {
 		   var view 				= require('views/policymanager/ServiceLayout');
 		   var RangerServiceDefList	= require('collections/RangerServiceDefList');
 		   var collection 			= new RangerServiceDefList();
-		   collection.queryParams.sortBy = 'id';
+		   collection.queryParams.sortBy = 'serviceTypeId';
 		   collection.fetch({
 			   cache : false,
 			   async:false

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/85d5658f/security-admin/src/main/webapp/scripts/views/common/XATableLayout.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/common/XATableLayout.js b/security-admin/src/main/webapp/scripts/views/common/XATableLayout.js
index 5556559..12bd6d7 100644
--- a/security-admin/src/main/webapp/scripts/views/common/XATableLayout.js
+++ b/security-admin/src/main/webapp/scripts/views/common/XATableLayout.js
@@ -122,16 +122,19 @@ define(function(require){
 			this.listenTo(this.collection, "sync reset", this.showHidePager);
 			
             this.listenTo(this.collection, 'request', function(){
-				$(this.rTableSpinner.el).addClass('loading');
+//				$(this.rTableSpinner.el).addClass('loading');
+				this.$el.find(this.rTableSpinner.el).addClass('loading');
 			},this);
             this.listenTo(this.collection, 'sync error', function(){
-				$(this.rTableSpinner.el).removeClass('loading');
+//				$(this.rTableSpinner.el).removeClass('loading');
+				this.$el.find(this.rTableSpinner.el).removeClass('loading');
 			},this);
 		},
 
 		/** on render callback */
 		onRender: function() {
 			this.initializePlugins();
+			
 			this.renderTable();
 			if(this.includePagination) {
 				this.renderPagination();
@@ -171,9 +174,10 @@ define(function(require){
 		},
 		showHidePager : function(){
 			if(this.collection.state && this.collection.state.totalRecords > XAGlobals.settings.PAGE_SIZE)	{
-				$(this.rPagination.el).show();
+				this.$el.find(this.rPagination.el).show()
+				//$(this.rPagination.el).show();
 			} else {
-				$(this.rPagination.el).hide();
+				this.$el.find(this.rPagination.el).hide();
 			}
 		},
 		renderFilter : function(){

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/85d5658f/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js b/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js
index b938c66..686836b 100644
--- a/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js
+++ b/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js
@@ -262,19 +262,16 @@ define(function(require) {
 					if(that.model.has('accesses')){
 							perms = that.model.get('accesses');
 					}
-					//reset isAllowed flag in accesssItems to set newly isAllowed
-					_.each(that.accessItems, function(item){ item.isAllowed = false });
 					
-					_.each(that.accessTypes, function(obj) {
-						if(_.contains(values, obj.name)){
-							var type = obj.name
-							_.each(that.accessItems, function(item){ if(item.type == type) item.isAllowed = true });
+					var items=[];
+					_.each(that.accessItems, function(item){ 
+						if($.inArray( item.type, values) >= 0){
+							item.isAllowed = true;
+							items.push(item) ;
 						}
-					});
+					},this);
 					// Save form data to model
-					
-					if(!_.isEmpty(that.accessItems))
-						that.model.set('accesses', that.accessItems);
+					that.model.set('accesses', items);
 					
 					$(this).html(valArr.join(" "));
 					that.ui.addPermissionsSpan.find('i').attr('class', 'icon-pencil');

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/85d5658f/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js
index bcbb3e0..42b5f68 100644
--- a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js
+++ b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js
@@ -455,14 +455,14 @@ define(function(require){
 						},
 						results: function (data, page) { 
 							var results = [];
-							if(data.length > 0){
-								results = data.map(function(m, i){	return {id : m, text: m};	});
-							}
-							/*if(!_.isUndefined(data)){
+							if(!_.isUndefined(data)){
+								if(_.isArray(data) && data.length > 0){
+									results = data.map(function(m, i){	return {id : m, text: m};	});
+								}
 								if(data.resultSize != "0"){
 									results = data.vXStrings.map(function(m, i){	return {id : m.value, text: m.value};	});
 								}
-							}*/
+							}
 							return { 
 								results : results
 							};


Mime
View raw message