ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sneet...@apache.org
Subject git commit: ARGUS-26: patch to improve public API for policy management
Date Tue, 26 Aug 2014 03:10:22 GMT
Repository: incubator-argus
Updated Branches:
  refs/heads/master 6cc76fdd7 -> eb8a9f59f


ARGUS-26: patch to improve public API for policy management


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

Branch: refs/heads/master
Commit: eb8a9f59f13fbfc43b47641a2f002a4d49187495
Parents: 6cc76fd
Author: sneethiraj <sneethir@apache.org>
Authored: Mon Aug 25 19:52:13 2014 -0700
Committer: sneethiraj <sneethir@apache.org>
Committed: Mon Aug 25 19:52:13 2014 -0700

----------------------------------------------------------------------
 security-admin/pom.xml                          |   8 +
 .../main/java/com/xasecure/biz/AssetMgr.java    |  51 ++-
 .../java/com/xasecure/common/AppConstants.java  |  45 ++
 .../main/java/com/xasecure/rest/PublicAPIs.java |  21 +-
 .../com/xasecure/service/XPermMapService.java   |   8 +
 .../com/xasecure/service/XPolicyService.java    | 444 +++++++++++++++++--
 .../com/xasecure/service/XResourceService.java  |  17 +-
 .../main/java/com/xasecure/view/VXPolicy.java   |  75 +---
 .../java/com/xasecure/rest/TestPublicAPIs.java  | 186 +++++++-
 9 files changed, 714 insertions(+), 141 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/eb8a9f59/security-admin/pom.xml
----------------------------------------------------------------------
diff --git a/security-admin/pom.xml b/security-admin/pom.xml
index 0b767db..0339996 100644
--- a/security-admin/pom.xml
+++ b/security-admin/pom.xml
@@ -392,5 +392,13 @@
 
 	</plugins>
 </pluginManagement>
+
+	<resources>
+		<resource>
+			<directory>src/main/resources</directory>
+			<filtering>true</filtering>
+		</resource>
+	</resources>
+
   </build>
 </project>

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/eb8a9f59/security-admin/src/main/java/com/xasecure/biz/AssetMgr.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/biz/AssetMgr.java b/security-admin/src/main/java/com/xasecure/biz/AssetMgr.java
index 91dcd38..2311bb3 100644
--- a/security-admin/src/main/java/com/xasecure/biz/AssetMgr.java
+++ b/security-admin/src/main/java/com/xasecure/biz/AssetMgr.java
@@ -22,6 +22,7 @@ import javax.naming.ldap.LdapName;
 import javax.naming.ldap.Rdn;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 import org.codehaus.jackson.JsonGenerationException;
 import org.codehaus.jackson.map.JsonMappingException;
@@ -167,9 +168,37 @@ public class AssetMgr extends AssetMgrBase {
 		}else if (xAsset.getAssetType() == AppConstants.ASSET_STORM) {
 			createResourcePathForStorm(vXResource);
 		}
+		
+		String resourceName = vXResource.getName();
+		String[] orgResNameList = stringUtil.split(resourceName, ",");
+		List<String> newResNameList = new ArrayList<String>();
+		for(String resName : orgResNameList) {
+			if(resName.length() > 0 && (resName.substring(resName.length()-1).equalsIgnoreCase("/"))) {
+				resName = resName.substring(0, resName.length()-1);
+				newResNameList.add(resName);
+				logger.info("Resource Name is not valid : " +resName + " Ignoring last /");
+			} else {
+				newResNameList.add(resName);
+			}
+		}
+		String updResName = StringUtils.join(newResNameList, ",");
+		vXResource.setName(updResName);
+		
 		SearchCriteria searchCriteria=new SearchCriteria();
 		searchCriteria.getParamList().put("assetId", vXResource.getAssetId());
 		searchCriteria.getParamList().put("fullname", vXResource.getName());
+		
+		if (xAsset.getAssetType() == AppConstants.ASSET_HIVE) {
+			if(stringUtil.isEmpty(vXResource.getUdfs())) {
+				searchCriteria.addParam("tableType", vXResource.getTableType());
+				searchCriteria.addParam("columnType", vXResource.getColumnType());
+			} else {
+				searchCriteria.addParam("udfs", vXResource.getUdfs());
+			}
+		} else if (xAsset.getAssetType() == AppConstants.ASSET_HDFS) {
+			searchCriteria.addParam("isRecursive", vXResource.getIsRecursive());
+		}
+		
 		VXResourceList vXResourceList=xResourceService.searchXResources(searchCriteria);		
 		if(vXResourceList!=null && vXResourceList.getListSize()>0){
 			logger.error("policy already exist with resource "+vXResource.getName());
@@ -288,6 +317,18 @@ public class AssetMgr extends AssetMgrBase {
 		SearchCriteria searchCriteria = new SearchCriteria();
 		searchCriteria.getParamList().put("assetId", vXResource.getAssetId());
 		searchCriteria.getParamList().put("fullname", vXResource.getName());
+		
+		if (xAsset.getAssetType() == AppConstants.ASSET_HIVE) {
+			if(stringUtil.isEmpty(vXResource.getUdfs())) {
+				searchCriteria.addParam("tableType", vXResource.getTableType());
+				searchCriteria.addParam("columnType", vXResource.getColumnType());
+			} else {
+				searchCriteria.addParam("udfs", vXResource.getUdfs());
+			}
+		} else if (xAsset.getAssetType() == AppConstants.ASSET_HDFS) {
+			searchCriteria.addParam("isRecursive", vXResource.getIsRecursive());
+		}
+		
 		VXResourceList vXResourceList=xResourceService.searchXResources(searchCriteria);		
 		if(vXResourceList!=null && vXResourceList.getListSize()>0){
 			for(VXResource vXResourceTemp :vXResourceList.getList()){
@@ -1185,13 +1226,17 @@ public class AssetMgr extends AssetMgrBase {
 				vXUser=xUserMgr.createXUser(vXUser);
 				//vXUser = xUserService.createResource(vXUser);
 			}
+			
+			Random rand = new Random();
+			String permGrp = new Date() + " : " + rand.nextInt(9999);
+			
 			VXPermMap vXPermMap = new VXPermMap();
 			vXPermMap.setUserId(vXUser.getId());
 			vXPermMap.setResourceId(vXResource.getId());
+			vXPermMap.setPermGroup(permGrp);
 			xPermMapService.createResource(vXPermMap);
 			
 			if (assetType == AppConstants.ASSET_KNOX) {
-				Random rand = new Random();
 				String permGroup = new Date() + " : " + rand.nextInt(9999);
 
 				VXPermMap permAdmin = new VXPermMap();
@@ -2188,9 +2233,13 @@ public class AssetMgr extends AssetMgrBase {
 				vXUser=xUserMgr.createXUser(vXUser);
 				//vXUser = xUserService.createResource(vXUser);
 			}
+			Random rand = new Random();
+			String permGrp = new Date() + " : " + rand.nextInt(9999);
+			
 			VXPermMap vXPermMap = new VXPermMap();
 			vXPermMap.setUserId(vXUser.getId());
 			vXPermMap.setResourceId(vXResource.getId());
+			vXPermMap.setPermGroup(permGrp);
 			xPermMapService.createResource(vXPermMap);
 		}
 		VXAuditMap vXAuditMap = new VXAuditMap();

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/eb8a9f59/security-admin/src/main/java/com/xasecure/common/AppConstants.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/common/AppConstants.java b/security-admin/src/main/java/com/xasecure/common/AppConstants.java
index 7cc1f50..215c418 100644
--- a/security-admin/src/main/java/com/xasecure/common/AppConstants.java
+++ b/security-admin/src/main/java/com/xasecure/common/AppConstants.java
@@ -815,6 +815,51 @@ public class AppConstants extends XACommonEnums {
 		if (label.equalsIgnoreCase("All")) {
 			return AppConstants.XA_PERM_TYPE_ALL; // XA_PERM_TYPE_ALL
 		}
+		if(label.equalsIgnoreCase("Allow")) {
+			return AppConstants.XA_PERM_TYPE_ALLOW; //XA_PERM_TYPE_ALLOW
+		}
+		if(label.equalsIgnoreCase("Submit Topology")) {
+			return AppConstants.XA_PERM_TYPE_SUBMIT_TOPOLOGY; //XA_PERM_TYPE_SUBMIT_TOPOLOGY
+		}
+		if(label.equalsIgnoreCase("File Upload")) {
+			return AppConstants.XA_PERM_TYPE_FILE_UPLOAD; //XA_PERM_TYPE_FILE_UPLOAD
+		}
+		if(label.equalsIgnoreCase("Get Nimbus Conf")) {
+			return AppConstants.XA_PERM_TYPE_GET_NIMBUS; //XA_PERM_TYPE_GET_NIMBUS
+		}
+		if(label.equalsIgnoreCase("Get Cluster Info")) {
+			return AppConstants.XA_PERM_TYPE_GET_CLUSTER_INFO; //XA_PERM_TYPE_GET_CLUSTER_INFO
+		}
+		if(label.equalsIgnoreCase("File Download")) {
+			return AppConstants.XA_PERM_TYPE_FILE_DOWNLOAD; //XA_PERM_TYPE_FILE_DOWNLOAD
+		}
+		if(label.equalsIgnoreCase("Kill Topology")) {
+			return AppConstants.XA_PERM_TYPE_KILL_TOPOLOGY; //XA_PERM_TYPE_KILL_TOPOLOGY
+		}
+		if(label.equalsIgnoreCase("Rebalance")) {
+			return AppConstants.XA_PERM_TYPE_REBALANCE; //XA_PERM_TYPE_REBALANCE
+		}
+		if(label.equalsIgnoreCase("Activate")) {
+			return AppConstants.XA_PERM_TYPE_ACTIVATE; //XA_PERM_TYPE_ACTIVATE
+		}
+		if(label.equalsIgnoreCase("Deactivate")) {
+			return AppConstants.XA_PERM_TYPE_DEACTIVATE; //XA_PERM_TYPE_DEACTIVATE
+		}
+		if(label.equalsIgnoreCase("Get Topology Conf")) {
+			return AppConstants.XA_PERM_TYPE_GET_TOPOLOGY_CONF; //XA_PERM_TYPE_GET_TOPOLOGY_CONF
+		}
+		if(label.equalsIgnoreCase("Get Topology")) {
+			return AppConstants.XA_PERM_TYPE_GET_TOPOLOGY; //XA_PERM_TYPE_GET_TOPOLOGY
+		}
+		if(label.equalsIgnoreCase("Get User Topology")) {
+			return AppConstants.XA_PERM_TYPE_GET_USER_TOPOLOGY; //XA_PERM_TYPE_GET_USER_TOPOLOGY
+		}
+		if(label.equalsIgnoreCase("Get Topology Info")) {
+			return AppConstants.XA_PERM_TYPE_GET_TOPOLOGY_INFO; //XA_PERM_TYPE_GET_TOPOLOGY_INFO
+		}
+		if(label.equalsIgnoreCase("Upload New Credential")) {
+			return AppConstants.XA_PERM_TYPE_UPLOAD_NEW_CREDENTIAL; //XA_PERM_TYPE_UPLOAD_NEW_CREDENTIAL
+		}
 		return 0;
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/eb8a9f59/security-admin/src/main/java/com/xasecure/rest/PublicAPIs.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/rest/PublicAPIs.java b/security-admin/src/main/java/com/xasecure/rest/PublicAPIs.java
index 5e721b4..469237d 100644
--- a/security-admin/src/main/java/com/xasecure/rest/PublicAPIs.java
+++ b/security-admin/src/main/java/com/xasecure/rest/PublicAPIs.java
@@ -26,6 +26,7 @@ import com.xasecure.common.StringUtil;
 import com.xasecure.common.XASearchUtil;
 import com.xasecure.common.annotation.XAAnnotationClassName;
 import com.xasecure.common.annotation.XAAnnotationJSMgrName;
+import com.xasecure.db.XADaoManager;
 import com.xasecure.service.AbstractBaseResourceService;
 import com.xasecure.service.XPolicyService;
 import com.xasecure.service.XRepositoryService;
@@ -74,6 +75,9 @@ public class PublicAPIs {
 	@Autowired
 	StringUtil stringUtil;
 
+	@Autowired
+	XADaoManager xaDaoMgr;
+
 	@GET
 	@Path("/api/repository/{id}")
 	@Produces({ "application/xml", "application/json" })
@@ -92,9 +96,11 @@ public class PublicAPIs {
 	}
 
 	@PUT
-	@Path("/api/repository/")
+	@Path("/api/repository/{id}")
 	@Produces({ "application/xml", "application/json" })
-	public VXRepository updateRepository(VXRepository vXRepository) {
+	public VXRepository updateRepository(VXRepository vXRepository,
+			@PathParam("id") Long id) {
+		vXRepository.setId(id);
 		VXAsset vXAsset = xRepositoryService.mapPublicToXAObject(vXRepository);
 		vXAsset = assetMgr.updateXAsset(vXAsset);
 		return xRepositoryService.mapXAToPublicObject(vXAsset);
@@ -108,7 +114,7 @@ public class PublicAPIs {
 			@Context HttpServletRequest request) {
 
 		String forceStr = request.getParameter("force");
-		boolean force = false;
+		boolean force = true;
 		if (!stringUtil.isEmpty(forceStr)) {
 			force = Boolean.parseBoolean(forceStr.trim());
 		}
@@ -163,17 +169,20 @@ public class PublicAPIs {
 		VXResource vXResource = xPolicyService.mapPublicToXAObject(vXPolicy,
 				AbstractBaseResourceService.OPERATION_CREATE_CONTEXT);
 		vXResource = assetMgr.createXResource(vXResource);
+		vXResource.setPermMapList(xPolicyService.updatePermGroup(vXResource));
 		return xPolicyService.mapXAToPublicObject(vXResource);
 
 	}
 
 	@PUT
-	@Path("/api/policy")
+	@Path("/api/policy/{id}")
 	@Produces({ "application/xml", "application/json" })
-	public VXPolicy updatePolicy(VXPolicy vXPolicy) {
+	public VXPolicy updatePolicy(VXPolicy vXPolicy, @PathParam("id") Long id) {
+		vXPolicy.setId(id);
 		VXResource vXResource = xPolicyService.mapPublicToXAObject(vXPolicy,
 				AbstractBaseResourceService.OPERATION_UPDATE_CONTEXT);
 		vXResource = assetMgr.updateXResource(vXResource);
+		vXResource.setPermMapList(xPolicyService.updatePermGroup(vXResource));
 		return xPolicyService.mapXAToPublicObject(vXResource);
 	}
 
@@ -184,7 +193,7 @@ public class PublicAPIs {
 	public void deletePolicy(@PathParam("id") Long id,
 			@Context HttpServletRequest request) {
 		String forceStr = request.getParameter("force");
-		boolean force = false;
+		boolean force = true;
 		if (!stringUtil.isEmpty(forceStr)) {
 			force = Boolean.parseBoolean(forceStr.trim());
 		}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/eb8a9f59/security-admin/src/main/java/com/xasecure/service/XPermMapService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/service/XPermMapService.java b/security-admin/src/main/java/com/xasecure/service/XPermMapService.java
index 36bd9a3..143e51b 100644
--- a/security-admin/src/main/java/com/xasecure/service/XPermMapService.java
+++ b/security-admin/src/main/java/com/xasecure/service/XPermMapService.java
@@ -47,6 +47,14 @@ public class XPermMapService extends XPermMapServiceBase<XXPermMap, VXPermMap> {
 	public XPermMapService() {
 		searchFields.add(new SearchField("resourceId", "obj.resourceId",
 				SearchField.DATA_TYPE.INTEGER, SearchField.SEARCH_TYPE.FULL));
+		searchFields.add(new SearchField("permType", "obj.permType",
+				SearchField.DATA_TYPE.INTEGER, SearchField.SEARCH_TYPE.FULL));
+		searchFields.add(new SearchField("permFor", "obj.permFor",
+				SearchField.DATA_TYPE.INTEGER, SearchField.SEARCH_TYPE.FULL));
+		searchFields.add(new SearchField("userId", "obj.userId",
+				SearchField.DATA_TYPE.INTEGER, SearchField.SEARCH_TYPE.FULL));
+		searchFields.add(new SearchField("groupId", "obj.groupId",
+				SearchField.DATA_TYPE.INTEGER, SearchField.SEARCH_TYPE.FULL));
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/eb8a9f59/security-admin/src/main/java/com/xasecure/service/XPolicyService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/service/XPolicyService.java b/security-admin/src/main/java/com/xasecure/service/XPolicyService.java
index 82d05f6..f18869d 100644
--- a/security-admin/src/main/java/com/xasecure/service/XPolicyService.java
+++ b/security-admin/src/main/java/com/xasecure/service/XPolicyService.java
@@ -6,20 +6,29 @@ package com.xasecure.service;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Random;
 
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.xasecure.common.AppConstants;
+import com.xasecure.common.DateUtil;
+import com.xasecure.common.MessageEnums;
 import com.xasecure.common.PropertiesUtil;
 import com.xasecure.common.RESTErrorUtil;
 import com.xasecure.common.SearchCriteria;
 import com.xasecure.common.StringUtil;
 import com.xasecure.db.XADaoManager;
+import com.xasecure.entity.XXAsset;
 import com.xasecure.entity.XXGroup;
+import com.xasecure.entity.XXPermMap;
+import com.xasecure.entity.XXResource;
 import com.xasecure.entity.XXUser;
 import com.xasecure.view.VXAuditMap;
 import com.xasecure.view.VXAuditMapList;
@@ -38,6 +47,7 @@ import com.xasecure.view.VXResourceList;
 
 @Service
 public class XPolicyService extends PublicAPIServiceBase<VXResource, VXPolicy> {
+	Logger logger = Logger.getLogger(XPolicyService.class);
 
 	@Autowired
 	RESTErrorUtil restErrorUtil;
@@ -54,6 +64,9 @@ public class XPolicyService extends PublicAPIServiceBase<VXResource, VXPolicy> {
 	@Autowired
 	XAuditMapService xAuditMapService;
 
+	@Autowired
+	XResourceService xResourceService;
+
 	String version;
 
 	public XPolicyService() {
@@ -67,10 +80,7 @@ public class XPolicyService extends PublicAPIServiceBase<VXResource, VXPolicy> {
 
 		vXPolicy.setPolicyName(vXResource.getPolicyName());
 		vXPolicy.setResourceName(vXResource.getName());
-		vXPolicy.setResourceType(AppConstants
-				.getLabelFor_ResourceType(vXResource.getResourceType()));
 		vXPolicy.setDescription(vXResource.getDescription());
-		vXPolicy.setRepositoryId(vXResource.getAssetId());
 		vXPolicy.setRepositoryName(vXResource.getAssetName());
 		vXPolicy.setRepositoryType(AppConstants
 				.getLabelFor_AssetType(vXResource.getAssetType()));
@@ -101,11 +111,6 @@ public class XPolicyService extends PublicAPIServiceBase<VXResource, VXPolicy> {
 			auditEnable = false;
 		}
 		vXPolicy.setAuditEnabled(auditEnable);
-
-		vXPolicy.setCheckParentPermission(AppConstants
-				.getBooleanFor_BooleanValue(vXResource
-						.getCheckParentPermission()));
-
 		vXPolicy.setVersion(version);
 
 		return vXPolicy;
@@ -119,23 +124,61 @@ public class XPolicyService extends PublicAPIServiceBase<VXResource, VXPolicy> {
 		vXResource.setName(vXPolicy.getResourceName());
 		vXResource.setPolicyName(vXPolicy.getPolicyName());
 		vXResource.setDescription(vXPolicy.getDescription());
-		vXResource.setResourceType(AppConstants
-				.getEnumFor_ResourceType(vXPolicy.getResourceType()));
-		vXResource.setAssetId(vXPolicy.getRepositoryId());
+		vXResource.setResourceType(getResourceType(vXPolicy));
+
+		XXAsset xAsset = xaDaoMgr.getXXAsset().findByAssetName(
+				vXPolicy.getRepositoryName());
+		if (xAsset == null) {
+			throw restErrorUtil.createRESTException("The repository for which "
+					+ "you're updating policy, doesn't exist.",
+					MessageEnums.INVALID_INPUT_DATA);
+		}
+		vXResource.setAssetId(xAsset.getId());
 
 		if (operationContext == AbstractBaseResourceService.OPERATION_UPDATE_CONTEXT) {
+			XXResource xxResource = xaDaoMgr.getXXResource().getById(
+					vXPolicy.getId());
+			if (xxResource == null) {
+				logger.error("No policy found with given Id : "
+						+ vXPolicy.getId());
+				throw restErrorUtil
+						.createRESTException("No Policy found with given Id : "
+								+ vXResource.getId(),
+								MessageEnums.DATA_NOT_FOUND);
+			}
+			/*
+			 * While updating public object we wont have createDate/updateDate,
+			 * so create time, addedById, updatedById, etc. we ll have to take
+			 * from existing object
+			 */
+
+			xxResource.setUpdateTime(DateUtil.getUTCDate());
+			xResourceService
+					.mapBaseAttributesToViewBean(xxResource, vXResource);
 
 			SearchCriteria scAuditMap = new SearchCriteria();
-			scAuditMap.addParam("resourceId", vXPolicy.getId());
+			scAuditMap.addParam("resourceId", xxResource.getId());
 			VXAuditMapList vXAuditMapList = xAuditMapService
 					.searchXAuditMaps(scAuditMap);
-			vXResource.setAuditList(vXAuditMapList.getVXAuditMaps());
 
-			SearchCriteria scPermMap = new SearchCriteria();
-			scPermMap.addParam("resourceId", vXPolicy.getId());
-			VXPermMapList vXPermMapList = xPermMapService
-					.searchXPermMaps(scPermMap);
-			vXResource.setPermMapList(vXPermMapList.getVXPermMaps());
+			List<VXAuditMap> auditList = new ArrayList<VXAuditMap>();
+
+			if (vXAuditMapList.getListSize() > 0 && vXPolicy.isAuditEnabled()) {
+				auditList.addAll(vXAuditMapList.getVXAuditMaps());
+			} else if (vXAuditMapList.getListSize() == 0
+					&& vXPolicy.isAuditEnabled()) {
+				VXAuditMap vXAuditMap = new VXAuditMap();
+				vXAuditMap.setAuditType(AppConstants.XA_AUDIT_TYPE_ALL);
+				auditList.add(vXAuditMap);
+
+			}
+
+			List<VXPermMap> permMapList = mapPermObjToPermList(
+					vXPolicy.getPermMapList(), vXPolicy);
+
+			vXResource.setAuditList(auditList);
+			vXResource.setPermMapList(permMapList);
+
 		} else if (operationContext == AbstractBaseResourceService.OPERATION_CREATE_CONTEXT) {
 
 			if (vXPolicy.isAuditEnabled()) {
@@ -146,7 +189,6 @@ public class XPolicyService extends PublicAPIServiceBase<VXResource, VXPolicy> {
 
 				vXResource.setAuditList(auditList);
 			}
-
 			if (!stringUtil.isEmpty(vXPolicy.getPermMapList())) {
 				List<VXPermMap> permMapList = mapPermObjToPermList(vXPolicy
 						.getPermMapList());
@@ -170,8 +212,8 @@ public class XPolicyService extends PublicAPIServiceBase<VXResource, VXPolicy> {
 			resourceStatus = AppConstants.STATUS_DISABLED;
 		}
 		vXResource.setResourceStatus(resourceStatus);
-		vXResource.setCheckParentPermission(AppConstants
-				.getEnumFor_BooleanValue(vXPolicy.getCheckParentPermission()));
+		// Allowing to create policy without checking parent permission
+		vXResource.setCheckParentPermission(AppConstants.BOOL_FALSE);
 		vXResource.setTopologies(vXPolicy.getTopologies());
 		vXResource.setServices(vXPolicy.getServices());
 		vXResource.setTableType(AppConstants.getEnumFor_PolicyType(vXPolicy
@@ -182,56 +224,138 @@ public class XPolicyService extends PublicAPIServiceBase<VXResource, VXPolicy> {
 		return vXResource;
 	}
 
-	private List<VXPermMap> mapPermObjToPermList(List<VXPermObj> permObjList) {
+	private List<VXPermMap> mapPermObjToPermList(List<VXPermObj> permObjList,
+			VXPolicy vXPolicy) {
 
+		Long resId = vXPolicy.getId();
 		List<VXPermMap> permMapList = new ArrayList<VXPermMap>();
+		List<VXPermMap> updPermMapList = new ArrayList<VXPermMap>();
+		Map<String, VXPermMap> newPermMap = new LinkedHashMap<String, VXPermMap>();
 		Random rand = new Random();
 
+		Map<String, XXPermMap> prevPermMap = getPrevPermMap(resId);
+
+		if (permObjList == null) {
+			permObjList = new ArrayList<VXPermObj>();
+		}
 		for (VXPermObj permObj : permObjList) {
+			String permGrp = new Date() + " : " + rand.nextInt(9999);
 
 			if (!stringUtil.isEmpty(permObj.getUserList())) {
-				for (String user : permObj.getUserList()) {
+				int permFor = AppConstants.XA_PERM_FOR_USER;
 
-					String permGrp = new Date() + " : " + rand.nextInt(9999);
+				for (String user : permObj.getUserList()) {
 
 					XXUser xxUser = xaDaoMgr.getXXUser().findByUserName(user);
+					if (xxUser == null) {
+						logger.error("No User found with this name : " + user);
+						throw restErrorUtil.createRESTException(
+								"No User found with name : " + user,
+								MessageEnums.DATA_NOT_FOUND);
+					}
+					Long userId = xxUser.getId();
 					for (String permission : permObj.getPermList()) {
 
-						VXPermMap vXPermMap = new VXPermMap();
 						int permType = AppConstants
 								.getEnumFor_XAPermType(permission);
+						VXPermMap vXPermMap = new VXPermMap();
 						vXPermMap.setPermFor(AppConstants.XA_PERM_FOR_USER);
 						vXPermMap.setPermGroup(permGrp);
 						vXPermMap.setPermType(permType);
 						vXPermMap.setUserId(xxUser.getId());
-
+						vXPermMap.setResourceId(resId);
 						permMapList.add(vXPermMap);
+
+						StringBuilder uniqueKey = new StringBuilder();
+						uniqueKey.append(resId + "_");
+						uniqueKey.append(permFor + "_");
+						uniqueKey.append(userId + "_");
+						uniqueKey.append(permType);
+						newPermMap.put(uniqueKey.toString(), vXPermMap);
 					}
 				}
 			}
 			if (!stringUtil.isEmpty(permObj.getGroupList())) {
-				for (String group : permObj.getGroupList()) {
+				int permFor = AppConstants.XA_PERM_FOR_GROUP;
 
-					String permGrp = new Date() + " : " + rand.nextInt(9999);
+				for (String group : permObj.getGroupList()) {
 
 					XXGroup xxGroup = xaDaoMgr.getXXGroup().findByGroupName(
 							group);
+					if (xxGroup == null) {
+						logger.error("No UserGroup found with this name : "
+								+ group);
+						throw restErrorUtil.createRESTException(
+								"No User found with name : " + group,
+								MessageEnums.DATA_NOT_FOUND);
+					}
+					Long grpId = xxGroup.getId();
 					for (String permission : permObj.getPermList()) {
 
-						VXPermMap vXPermMap = new VXPermMap();
 						int permType = AppConstants
 								.getEnumFor_XAPermType(permission);
+						VXPermMap vXPermMap = new VXPermMap();
 						vXPermMap.setPermFor(AppConstants.XA_PERM_FOR_GROUP);
 						vXPermMap.setPermGroup(permGrp);
 						vXPermMap.setPermType(permType);
-						vXPermMap.setUserId(xxGroup.getId());
-
+						vXPermMap.setGroupId(xxGroup.getId());
+						vXPermMap.setResourceId(resId);
 						permMapList.add(vXPermMap);
+
+						StringBuilder uniqueKey = new StringBuilder();
+						uniqueKey.append(resId + "_");
+						uniqueKey.append(permFor + "_");
+						uniqueKey.append(grpId + "_");
+						uniqueKey.append(permType);
+						newPermMap.put(uniqueKey.toString(), vXPermMap);
 					}
 				}
 			}
 		}
-		return permMapList;
+
+		// Create Newly added permissions and Remove deleted permissions from DB
+		if (prevPermMap.size() == 0) {
+			updPermMapList.addAll(permMapList);
+		} else {
+			for (Entry<String, VXPermMap> entry : newPermMap.entrySet()) {
+				if (!prevPermMap.containsKey(entry.getKey())) {
+					updPermMapList.add(entry.getValue());
+				} else {
+					VXPermMap vPMap = xPermMapService
+							.populateViewBean(prevPermMap.get(entry.getKey()));
+					updPermMapList.add(vPMap);
+				}
+			}
+		}
+		return updPermMapList;
+	}
+
+	private Map<String, XXPermMap> getPrevPermMap(Long resId) {
+		List<XXPermMap> xxPermMapList = xaDaoMgr.getXXPermMap()
+				.findByResourceId(resId);
+
+		Map<String, XXPermMap> prevPermMap = new LinkedHashMap<String, XXPermMap>();
+
+		for (XXPermMap xxPermMap : xxPermMapList) {
+			int permFor = xxPermMap.getPermFor();
+			Long userId = xxPermMap.getUserId();
+			Long grpId = xxPermMap.getGroupId();
+			int permType = xxPermMap.getPermType();
+
+			StringBuilder uniqueKey = new StringBuilder();
+			uniqueKey.append(resId + "_");
+			uniqueKey.append(permFor + "_");
+
+			if (userId != null) {
+				uniqueKey.append(userId + "_");
+			} else if (grpId != null) {
+				uniqueKey.append(grpId + "_");
+			}
+			uniqueKey.append(permType);
+			prevPermMap.put(uniqueKey.toString(), xxPermMap);
+		}
+
+		return prevPermMap;
 	}
 
 	public List<VXPermObj> mapPermMapToPermObj(List<VXPermMap> permMapList) {
@@ -239,15 +363,17 @@ public class XPolicyService extends PublicAPIServiceBase<VXResource, VXPolicy> {
 		List<VXPermObj> permObjList = new ArrayList<VXPermObj>();
 		HashMap<String, List<VXPermMap>> sortedPemMap = new HashMap<String, List<VXPermMap>>();
 
-		for (VXPermMap vXPermMap : permMapList) {
+		if (permMapList != null) {
+			for (VXPermMap vXPermMap : permMapList) {
 
-			String permGrp = vXPermMap.getPermGroup();
-			List<VXPermMap> sortedList = sortedPemMap.get(permGrp);
-			if (sortedList == null) {
-				sortedList = new ArrayList<VXPermMap>();
-				sortedPemMap.put(permGrp, sortedList);
+				String permGrp = vXPermMap.getPermGroup();
+				List<VXPermMap> sortedList = sortedPemMap.get(permGrp);
+				if (sortedList == null) {
+					sortedList = new ArrayList<VXPermMap>();
+					sortedPemMap.put(permGrp, sortedList);
+				}
+				sortedList.add(vXPermMap);
 			}
-			sortedList.add(vXPermMap);
 		}
 
 		for (Entry<String, List<VXPermMap>> entry : sortedPemMap.entrySet()) {
@@ -257,14 +383,26 @@ public class XPolicyService extends PublicAPIServiceBase<VXResource, VXPolicy> {
 			List<String> permList = new ArrayList<String>();
 			String ipAddress = "";
 
-			for (VXPermMap permMap : entry.getValue()) {
+			List<VXPermMap> permListForGrp = entry.getValue();
+
+			for (VXPermMap permMap : permListForGrp) {
 				if (permMap.getPermFor() == AppConstants.XA_PERM_FOR_USER) {
 					userList.add(permMap.getUserName());
 				} else if (permMap.getPermFor() == AppConstants.XA_PERM_FOR_GROUP) {
 					groupList.add(permMap.getGroupName());
+					if (!userList.contains(permMap.getUserName())) {
+						userList.add(permMap.getUserName());
+					}
+				} else if (permMap.getPermFor() == AppConstants.XA_PERM_FOR_GROUP) {
+					if (!groupList.contains(permMap.getGroupName())) {
+						groupList.add(permMap.getGroupName());
+					}
+				}
+				String perm = AppConstants.getLabelFor_XAPermType(permMap
+						.getPermType());
+				if (!permList.contains(perm)) {
+					permList.add(perm);
 				}
-				permList.add(AppConstants.getLabelFor_XAPermType(permMap
-						.getPermType()));
 				ipAddress = permMap.getIpAddress();
 			}
 			if (!userList.isEmpty()) {
@@ -292,4 +430,226 @@ public class XPolicyService extends PublicAPIServiceBase<VXResource, VXPolicy> {
 		return vXPolicyList;
 	}
 
+	private List<VXPermMap> mapPermObjToPermList(List<VXPermObj> permObjList) {
+
+		List<VXPermMap> permMapList = new ArrayList<VXPermMap>();
+		Random rand = new Random();
+
+		for (VXPermObj permObj : permObjList) {
+
+			if (!stringUtil.isEmpty(permObj.getUserList())) {
+				String permGrp = new Date() + " : " + rand.nextInt(9999);
+				for (String user : permObj.getUserList()) {
+
+					XXUser xxUser = xaDaoMgr.getXXUser().findByUserName(user);
+					if (xxUser == null) {
+						logger.error("No User found with this name : " + user);
+						throw restErrorUtil.createRESTException(
+								"No User found with name : " + user,
+								MessageEnums.DATA_NOT_FOUND);
+					}
+					for (String permission : permObj.getPermList()) {
+
+						VXPermMap vXPermMap = new VXPermMap();
+						int permType = AppConstants
+								.getEnumFor_XAPermType(permission);
+						vXPermMap.setPermFor(AppConstants.XA_PERM_FOR_USER);
+						vXPermMap.setPermGroup(permGrp);
+						vXPermMap.setPermType(permType);
+						vXPermMap.setUserId(xxUser.getId());
+
+						permMapList.add(vXPermMap);
+					}
+				}
+			}
+			if (!stringUtil.isEmpty(permObj.getGroupList())) {
+				String permGrp = new Date() + " : " + rand.nextInt(9999);
+				for (String group : permObj.getGroupList()) {
+
+					XXGroup xxGroup = xaDaoMgr.getXXGroup().findByGroupName(
+							group);
+					if (xxGroup == null) {
+						logger.error("No UserGroup found with this name : "
+								+ group);
+						throw restErrorUtil.createRESTException(
+								"No User found with name : " + group,
+								MessageEnums.DATA_NOT_FOUND);
+					}
+
+					for (String permission : permObj.getPermList()) {
+
+						VXPermMap vXPermMap = new VXPermMap();
+						int permType = AppConstants
+								.getEnumFor_XAPermType(permission);
+						vXPermMap.setPermFor(AppConstants.XA_PERM_FOR_GROUP);
+						vXPermMap.setPermGroup(permGrp);
+						vXPermMap.setPermType(permType);
+						vXPermMap.setGroupId(xxGroup.getId());
+
+						permMapList.add(vXPermMap);
+					}
+				}
+			}
+		}
+		return permMapList;
+	}
+
+	public List<VXPermMap> updatePermGroup(VXResource vXResource) {
+
+		XXResource xxResource = xaDaoMgr.getXXResource().getById(
+				vXResource.getId());
+		if (xxResource == null) {
+			logger.info("Resource : " + vXResource.getPolicyName()
+					+ " Not Found, while updating PermGroup");
+			throw restErrorUtil.createRESTException(
+					"Resource Not found to update PermGroup",
+					MessageEnums.DATA_NOT_FOUND);
+		}
+		Long resId = vXResource.getId();
+		List<VXPermMap> updatedPermMapList = new ArrayList<VXPermMap>();
+
+		SearchCriteria searchCriteria = new SearchCriteria();
+		searchCriteria.addParam("resourceId", resId);
+		VXPermMapList currentPermMaps = xPermMapService
+				.searchXPermMaps(searchCriteria);
+
+		List<VXPermMap> currentPermMapList = currentPermMaps.getVXPermMaps();
+		HashMap<String, List<Integer>> userPermMap = new HashMap<String, List<Integer>>();
+
+		for (VXPermMap currentPermMap : currentPermMapList) {
+			Long userId = currentPermMap.getUserId();
+			Long groupId = currentPermMap.getGroupId();
+			int permFor = currentPermMap.getPermFor();
+			int permType = currentPermMap.getPermType();
+			String uniKey = resId + "_" + permFor;
+			if (permFor == AppConstants.XA_PERM_FOR_GROUP) {
+				uniKey = uniKey + "_" + groupId;
+			} else if (permFor == AppConstants.XA_PERM_FOR_USER) {
+				uniKey = uniKey + "_" + userId;
+			}
+
+			List<Integer> permList = userPermMap.get(uniKey);
+			if (permList == null) {
+				permList = new ArrayList<Integer>();
+				userPermMap.put(uniKey, permList);
+			}
+			permList.add(permType);
+		}
+
+		List<List<String>> masterKeyList = new ArrayList<List<String>>();
+		List<String> proceedKeyList = new ArrayList<String>();
+		for (Entry<String, List<Integer>> upMap : userPermMap.entrySet()) {
+
+			if (proceedKeyList.contains(upMap.getKey())) {
+				continue;
+			}
+
+			List<String> keyList = new ArrayList<String>();
+			keyList.add(upMap.getKey());
+			proceedKeyList.add(upMap.getKey());
+
+			for (Entry<String, List<Integer>> entry : userPermMap.entrySet()) {
+
+				if (proceedKeyList.contains(entry.getKey())) {
+					continue;
+				}
+
+				boolean result = compareTwoListElements(upMap.getValue(),
+						entry.getValue());
+				if (result) {
+					keyList.add(entry.getKey());
+					proceedKeyList.add(entry.getKey());
+				}
+			}
+			masterKeyList.add(keyList);
+		}
+
+		for (List<String> keyList : masterKeyList) {
+			Random rand = new Random();
+			String permGrp = new Date() + " : " + rand.nextInt(9999);
+			for (String key : keyList) {
+
+				SearchCriteria scPermMap = new SearchCriteria();
+				String[] keyEle = StringUtils.split(key, "_");
+				if (keyEle != null && keyEle.length == 3) {
+
+					int permFor = Integer.parseInt(keyEle[1]);
+					int ugId = Integer.parseInt(keyEle[2]);
+					scPermMap.addParam("resourceId", resId);
+					scPermMap.addParam("permFor", permFor);
+
+					if (permFor == AppConstants.XA_PERM_FOR_GROUP) {
+						scPermMap.addParam("groupId", ugId);
+					} else if (permFor == AppConstants.XA_PERM_FOR_USER) {
+						scPermMap.addParam("userId", ugId);
+					}
+
+					VXPermMapList permList = xPermMapService
+							.searchXPermMaps(scPermMap);
+					for (VXPermMap vXPerm : permList.getVXPermMaps()) {
+						vXPerm.setPermGroup(permGrp);
+						xPermMapService.updateResource(vXPerm);
+						updatedPermMapList.add(vXPerm);
+					}
+				} else {
+					logger.info("variable : keyEle, should fulfill the checked"
+							+ " condition, but its not fulfilling required "
+							+ "condition. Ignoring appropriate permMap from"
+							+ " updating permGroup. Key : " + key
+							+ "Resource Id : " + resId);
+				}
+			}
+		}
+		return updatedPermMapList;
+	}
+
+	private boolean compareTwoListElements(List<?> list1, List<?> list2) {
+		if (list1 == null || list2 == null) {
+			return false;
+		}
+		if (list1.size() != list2.size()) {
+			return false;
+		}
+		int listSize = list1.size();
+		for (int i = 0; i < listSize; i++) {
+			Object obj1 = list1.get(i);
+			if (!list2.contains(obj1)) {
+				return false;
+			}
+		}
+		return true;
+	}
+
+	public int getResourceType(VXPolicy vXPolicy) {
+		int resourceType = AppConstants.RESOURCE_PATH;
+		if (vXPolicy == null) {
+			return resourceType;
+		}
+		if (!stringUtil.isEmpty(vXPolicy.getDatabases())) {
+			resourceType = AppConstants.RESOURCE_DB;
+			if (!stringUtil.isEmpty(vXPolicy.getTables())) {
+				resourceType = AppConstants.RESOURCE_TABLE;
+			}
+			if (!stringUtil.isEmpty(vXPolicy.getColumns())) {
+				resourceType = AppConstants.RESOURCE_COLUMN;
+			}
+			if (!stringUtil.isEmpty(vXPolicy.getUdfs())) {
+				resourceType = AppConstants.RESOURCE_UDF;
+			}
+		} else if (!stringUtil.isEmpty(vXPolicy.getTables())) {
+			resourceType = AppConstants.RESOURCE_TABLE;
+			if (!stringUtil.isEmpty(vXPolicy.getColumnFamilies())) {
+				resourceType = AppConstants.RESOURCE_COL_FAM;
+			}
+			if (!stringUtil.isEmpty(vXPolicy.getColumns())) {
+				resourceType = AppConstants.RESOURCE_COLUMN;
+			}
+		} else if (!stringUtil.isEmpty(vXPolicy.getTopologies())) {
+			resourceType = AppConstants.RESOURCE_TOPOLOGY;
+			if (!stringUtil.isEmpty(vXPolicy.getServices())) {
+				resourceType = AppConstants.RESOURCE_SERVICE_NAME;
+			}
+		}
+		return resourceType;
+	}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/eb8a9f59/security-admin/src/main/java/com/xasecure/service/XResourceService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/service/XResourceService.java b/security-admin/src/main/java/com/xasecure/service/XResourceService.java
index 7925ea0..94395e3 100644
--- a/security-admin/src/main/java/com/xasecure/service/XResourceService.java
+++ b/security-admin/src/main/java/com/xasecure/service/XResourceService.java
@@ -12,6 +12,8 @@ import com.xasecure.common.ContextUtil;
 import com.xasecure.common.MessageEnums;
 import com.xasecure.common.SearchCriteria;
 import com.xasecure.common.SearchField;
+import com.xasecure.common.SearchField.DATA_TYPE;
+import com.xasecure.common.SearchField.SEARCH_TYPE;
 import com.xasecure.common.SortField;
 import com.xasecure.common.StringUtil;
 import com.xasecure.common.UserSessionBase;
@@ -19,6 +21,7 @@ import com.xasecure.common.XAConstants;
 import com.xasecure.view.VXResponse;
 
 import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Service;
@@ -127,15 +130,19 @@ public class XResourceService extends
 
 		searchFields.add(new SearchField("id", "obj.id", 
 				SearchField.DATA_TYPE.INTEGER, SearchField.SEARCH_TYPE.FULL));
+		searchFields.add(new SearchField("topologies", "obj.topologies",
+				SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.PARTIAL));
+		searchFields.add(new SearchField("services", "obj.services",
+				SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.PARTIAL));
+		searchFields.add(new SearchField("tableType", "obj.tableType",
+				DATA_TYPE.INTEGER, SEARCH_TYPE.FULL));
+		searchFields.add(new SearchField("columnType", "obj.columnType",
+				DATA_TYPE.INTEGER, SEARCH_TYPE.FULL));
 
 		sortFields.add(new SortField("name", "obj.name"));
 		sortFields.add(new SortField("isRecursive", "obj.isRecursive"));
 		sortFields.add(new SortField("isEncrypt", "obj.isEncrypt"));
 		
-		searchFields.add(new SearchField("topologies", "obj.topologies",
-				SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.PARTIAL));
-		searchFields.add(new SearchField("services", "obj.services",
-				SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.PARTIAL));
 	}
 
 	@Override
@@ -215,6 +222,8 @@ public class XResourceService extends
 //			}
 //		}
 		
+//		if(vObj.getAssetType())
+		
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/eb8a9f59/security-admin/src/main/java/com/xasecure/view/VXPolicy.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/view/VXPolicy.java b/security-admin/src/main/java/com/xasecure/view/VXPolicy.java
index 791016e..70f46a0 100644
--- a/security-admin/src/main/java/com/xasecure/view/VXPolicy.java
+++ b/security-admin/src/main/java/com/xasecure/view/VXPolicy.java
@@ -43,18 +43,10 @@ public class VXPolicy extends VXDataObject implements java.io.Serializable {
 	 */
 	protected String resourceName;
 	/**
-	 * ResourceType : Label of EnumType : ResourceType
-	 */
-	protected String resourceType;
-	/**
 	 * Description
 	 */
 	protected String description;
 	/**
-	 * Id of the repository
-	 */
-	protected Long repositoryId;
-	/**
 	 * Repository Name
 	 */
 	protected String repositoryName;
@@ -116,24 +108,17 @@ public class VXPolicy extends VXDataObject implements java.io.Serializable {
 	 */
 	protected boolean isAuditEnabled;
 	/**
-	 * Check parent permission This attribute is of type enum
-	 * CommonEnums::BooleanValue
-	 */
-	protected boolean checkParentPermission;
-	/**
 	 * Version No of Project
 	 */
 	protected String version;
 
 	protected String grantor;
+
 	/**
 	 * Default constructor. This will set all the attributes to default value.
 	 */
 	public VXPolicy() {
-		resourceType = AppConstants
-				.getLabelFor_ResourceType(AppConstants.RESOURCE_PATH);
 		isRecursive = false;
-		checkParentPermission = false;
 	}
 
 	/**
@@ -177,26 +162,6 @@ public class VXPolicy extends VXDataObject implements java.io.Serializable {
 	}
 
 	/**
-	 * This method sets the value to the member attribute <b>resourceType</b>.
-	 * You cannot set null to the attribute.
-	 * 
-	 * @param resourceType
-	 *            Value to set member attribute <b>resourceType</b>
-	 */
-	public void setResourceType(String resourceType) {
-		this.resourceType = resourceType;
-	}
-
-	/**
-	 * Returns the value for the member attribute <b>resourceType</b>
-	 * 
-	 * @return String - value of member attribute <b>resourceType</b>.
-	 */
-	public String getResourceType() {
-		return this.resourceType;
-	}
-
-	/**
 	 * This method sets the value to the member attribute <b>description</b>.
 	 * You cannot set null to the attribute.
 	 * 
@@ -217,21 +182,6 @@ public class VXPolicy extends VXDataObject implements java.io.Serializable {
 	}
 
 	/**
-	 * @return the repositoryId
-	 */
-	public Long getRepositoryId() {
-		return repositoryId;
-	}
-
-	/**
-	 * @param repositoryId
-	 *            the repositoryId to set
-	 */
-	public void setRepositoryId(Long repositoryId) {
-		this.repositoryId = repositoryId;
-	}
-
-	/**
 	 * This method sets the value to the member attribute <b>assetName</b>. You
 	 * cannot set null to the attribute.
 	 * 
@@ -532,26 +482,6 @@ public class VXPolicy extends VXDataObject implements java.io.Serializable {
 	}
 
 	/**
-	 * This method sets the value to the member attribute
-	 * <b>checkParentPermission</b>.
-	 * 
-	 * @param checkParentPermission
-	 *            Value to set member attribute <b>checkParentPermission</b>
-	 */
-	public void setCheckParentPermission(boolean checkParentPermission) {
-		this.checkParentPermission = checkParentPermission;
-	}
-
-	/**
-	 * Returns the value for the member attribute <b>checkParentPermission</b>
-	 * 
-	 * @return boolean - value of member attribute <b>checkParentPermission</b>.
-	 */
-	public boolean getCheckParentPermission() {
-		return this.checkParentPermission;
-	}
-
-	/**
 	 * Returns the value for the member attribute <b>version</b>
 	 * 
 	 * @return String - value of member attribute <b>version</b>.
@@ -571,7 +501,6 @@ public class VXPolicy extends VXDataObject implements java.io.Serializable {
 		this.version = version;
 	}
 
-	
 	public String getGrantor() {
 		return grantor;
 	}
@@ -595,7 +524,6 @@ public class VXPolicy extends VXDataObject implements java.io.Serializable {
 		str += super.toString();
 		str += "policyName={" + policyName + "} ";
 		str += "resourceName={" + resourceName + "} ";
-		str += "resourceType={" + resourceType + "} ";
 		str += "description={" + description + "} ";
 		str += "repositoryName={" + repositoryName + "} ";
 		str += "repositoryType={" + repositoryType + "} ";
@@ -611,7 +539,6 @@ public class VXPolicy extends VXDataObject implements java.io.Serializable {
 		str += "isEnable={" + isEnabled + "} ";
 		str += "isRecursive={" + isRecursive + "} ";
 		str += "isAuditEnabled={" + isAuditEnabled + "} ";
-		str += "checkParentPermission={" + checkParentPermission + "} ";
 		str += "version={" + version + "} ";
 		str += "}";
 		return str;

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/eb8a9f59/security-admin/src/test/java/com/xasecure/rest/TestPublicAPIs.java
----------------------------------------------------------------------
diff --git a/security-admin/src/test/java/com/xasecure/rest/TestPublicAPIs.java b/security-admin/src/test/java/com/xasecure/rest/TestPublicAPIs.java
index ce6f67e..dc9817a 100644
--- a/security-admin/src/test/java/com/xasecure/rest/TestPublicAPIs.java
+++ b/security-admin/src/test/java/com/xasecure/rest/TestPublicAPIs.java
@@ -47,10 +47,14 @@ public class TestPublicAPIs extends BaseTest {
 	VXRepository vXRepoHDFS;
 	VXRepository vXRepoHBase;
 	VXRepository vXRepoHive;
+	VXRepository vXRepoKnox;
+	VXRepository vXRepoStorm;
 
 	VXPolicy vXPolicyHDFS;
 	VXPolicy vXPolicyHBase;
 	VXPolicy vXPolicyHive;
+	VXPolicy vXPolicyKnox;
+	VXPolicy vXPolicyStorm;
 
 	@Override
 	public void init() {
@@ -75,6 +79,8 @@ public class TestPublicAPIs extends BaseTest {
 		vXRepoHDFS = new VXRepository();
 		vXRepoHBase = new VXRepository();
 		vXRepoHive = new VXRepository();
+		vXRepoKnox = new VXRepository();
+		vXRepoStorm = new VXRepository();
 
 		// Create HDFS Repository
 		String configHdfs = "{"
@@ -146,6 +152,36 @@ public class TestPublicAPIs extends BaseTest {
 
 		assertNotNull("Error while creating Repo for HBase", vXRepoHBase);
 		logger.info("Create : Repo for HBase created Successfully");
+
+		String configKnox = "{" + "  \"username\": \"policymgr_hive\" ,"
+				+ "  \"password\": \"policymgr_hive\","
+				+ "  \"knox.url\": \"jdbc:hive2://127.0.0.1:10000/default\","
+				+ "  \"commonNameForCertificate\": \"\"}";
+
+		vXRepoKnox.setConfig(configKnox);
+		vXRepoKnox.setName("knoxdev_" + GUIDUtil.genGUI());
+		vXRepoKnox.setDescription("Knox Repo.. from JUnit");
+		vXRepoKnox.setActive(true);
+		vXRepoKnox.setRepositoryType("Knox");
+		vXRepoKnox = publicAPIs.createRepository(vXRepoKnox);
+
+		assertNotNull("Error while creating Repo for Knox", vXRepoKnox);
+		logger.info("Create : Repo for Knox created Successfully");
+
+		String configStorm = "{" + "  \"username\": \"policymgr_hive\" ,"
+				+ "  \"password\": \"policymgr_hive\","
+				+ "  \"commonNameForCertificate\": \"\"}";
+
+		vXRepoStorm.setConfig(configStorm);
+		vXRepoStorm.setName("stormdev_" + GUIDUtil.genGUI());
+		vXRepoStorm.setDescription("Storm Repo.. from JUnit");
+		vXRepoStorm.setActive(true);
+		vXRepoStorm.setRepositoryType("Storm");
+		vXRepoStorm = publicAPIs.createRepository(vXRepoStorm);
+
+		assertNotNull("Error while creating Repo for Knox", vXRepoStorm);
+		logger.info("Create : Repo for Storm created Successfully");
+
 	}
 
 	/**
@@ -157,21 +193,24 @@ public class TestPublicAPIs extends BaseTest {
 
 		// Update HDFS Repo
 		vXRepoHDFS.setName("HDFS Repo Updated_" + GUIDUtil.genGUI());
-		vXRepoHDFS = publicAPIs.updateRepository(vXRepoHDFS);
+		vXRepoHDFS = publicAPIs
+				.updateRepository(vXRepoHDFS, vXRepoHDFS.getId());
 
 		assertNotNull("Error While updating Repo", vXRepoHDFS);
 		logger.info("Update : Repo for HDFS updated Successfully");
 
 		// Update HBase Repo
 		vXRepoHBase.setName("HBase Repo Updated_" + GUIDUtil.genGUI());
-		vXRepoHBase = publicAPIs.updateRepository(vXRepoHBase);
+		vXRepoHBase = publicAPIs.updateRepository(vXRepoHBase,
+				vXRepoHBase.getId());
 
 		assertNotNull("Error While updating Repo", vXRepoHBase);
 		logger.info("Update : Repo for HBase updated Successfully");
 
 		// Update HIVE Repo
 		vXRepoHive.setName("Hive Repo Updated_" + GUIDUtil.genGUI());
-		vXRepoHive = publicAPIs.updateRepository(vXRepoHive);
+		vXRepoHive = publicAPIs
+				.updateRepository(vXRepoHive, vXRepoHive.getId());
 
 		assertNotNull("Error While updating Repo", vXRepoHive);
 		logger.info("Update : Repo for Hive updated Successfully");
@@ -282,6 +321,8 @@ public class TestPublicAPIs extends BaseTest {
 		vXPolicyHDFS = new VXPolicy();
 		vXPolicyHBase = new VXPolicy();
 		vXPolicyHive = new VXPolicy();
+		vXPolicyKnox = new VXPolicy();
+		vXPolicyStorm = new VXPolicy();
 
 		// Create Policy for HDFS
 		createHDFSPolicy();
@@ -289,22 +330,118 @@ public class TestPublicAPIs extends BaseTest {
 		createHBasePolicy();
 		// Create Policy for Hive
 		createHivePolicy();
+		// Create Policy for Knox
+		createKnoxPolicy();
+		// Create Policy for Storm
+		createStormPolicy();
 
 	}
 
+	private void createStormPolicy() {
+		vXPolicyStorm.setPolicyName("HomePolicy_" + GUIDUtil.genGUI());
+		vXPolicyStorm.setDescription("home policy for Storm");
+		vXPolicyStorm.setRepositoryName(vXRepoStorm.getName());
+		vXPolicyStorm.setRepositoryType("Storm");
+		vXPolicyStorm.setAuditEnabled(true);
+		vXPolicyStorm.setEnabled(true);
+		vXPolicyStorm.setTopologies("topo1, topo2, topo3");
+
+		VXPermObj vXPermObj = new VXPermObj();
+		List<String> userList = new ArrayList<String>();
+		userList.add("policymgr");
+		vXPermObj.setUserList(userList);
+
+		List<String> permList = new ArrayList<String>();
+		permList.add("Get Nimbus Conf");
+		permList.add("Get Cluster Info");
+		permList.add("Rebalance");
+		vXPermObj.setPermList(permList);
+
+		VXPermObj vXPermObj2 = new VXPermObj();
+		List<String> userList2 = new ArrayList<String>();
+		List<String> permList2 = new ArrayList<String>();
+
+		userList2.add("policymgr_hbase");
+		userList2.add("policymgr_hive");
+
+		permList2.add("File Download");
+		permList2.add("File Upload");
+		vXPermObj2.setUserList(userList2);
+		vXPermObj2.setPermList(permList2);
+
+		List<VXPermObj> permObjList = new ArrayList<VXPermObj>();
+		permObjList.add(vXPermObj);
+		permObjList.add(vXPermObj2);
+
+		vXPolicyStorm.setPermMapList(permObjList);
+
+		vXPolicyStorm = publicAPIs.createPolicy(vXPolicyStorm);
+	}
+
+	private void createKnoxPolicy() {
+		vXPolicyKnox.setPolicyName("HomePolicy_" + GUIDUtil.genGUI());
+		vXPolicyKnox.setDescription("home policy for Knox");
+		vXPolicyKnox.setRepositoryName(vXRepoKnox.getName());
+		vXPolicyKnox.setRepositoryType("Knox");
+		vXPolicyKnox.setAuditEnabled(true);
+		vXPolicyKnox.setEnabled(true);
+		vXPolicyKnox.setTopologies("topo1, topo2, topo3");
+		vXPolicyKnox.setServices("service1, service2, service3");
+
+		VXPermObj vXPermObj = new VXPermObj();
+		List<String> userList = new ArrayList<String>();
+		userList.add("policymgr");
+		vXPermObj.setUserList(userList);
+
+		List<String> permList = new ArrayList<String>();
+		permList.add("Allow");
+		permList.add("Admin");
+		vXPermObj.setPermList(permList);
+
+		VXPermObj vXPermObj2 = new VXPermObj();
+		List<String> userList2 = new ArrayList<String>();
+		List<String> permList2 = new ArrayList<String>();
+
+		userList2.add("policymgr_hbase");
+		userList2.add("policymgr_hive");
+
+		permList2.add("Allow");
+		vXPermObj2.setUserList(userList2);
+		vXPermObj2.setPermList(permList2);
+
+		VXPermObj vXPermObj3 = new VXPermObj();
+		List<String> grpList = new ArrayList<String>();
+		List<String> permList3 = new ArrayList<String>();
+
+		grpList.add("Grp1");
+		grpList.add("Grp2");
+		permList3.add("Allow");
+		permList3.add("Admin");
+		vXPermObj3.setGroupList(grpList);
+		vXPermObj3.setPermList(permList3);
+		vXPermObj3.setUserList(userList);
+
+		List<VXPermObj> permObjList = new ArrayList<VXPermObj>();
+		permObjList.add(vXPermObj);
+		permObjList.add(vXPermObj2);
+		permObjList.add(vXPermObj3);
+
+		vXPolicyKnox.setPermMapList(permObjList);
+
+		vXPolicyKnox = publicAPIs.createPolicy(vXPolicyKnox);
+	}
+
 	private void createHivePolicy() {
 		vXPolicyHive.setPolicyName("HomePolicy_" + GUIDUtil.genGUI());
 		vXPolicyHive.setDatabases("vXPolicyHive_" + GUIDUtil.genGUI());
 		vXPolicyHive.setTables("finance,hr," + GUIDUtil.genGUI());
 		vXPolicyHive.setColumns("amt, emp_id, " + GUIDUtil.genGUI());
 		vXPolicyHive.setDescription("home policy for Hive");
-		// vXPolicyHive.setRepositoryName(vXRepoHive.getName());
+		vXPolicyHive.setRepositoryName(vXRepoHive.getName());
 		vXPolicyHive.setRepositoryType("Hive");
 		vXPolicyHive.setEnabled(true);
 		vXPolicyHive.setRecursive(true);
 		vXPolicyHive.setAuditEnabled(true);
-		vXPolicyHive.setRepositoryId(vXRepoHive.getId());
-		vXPolicyHive.setResourceType("Column");
 		vXPolicyHive.setColumnType("Exclusion");
 
 		VXPermObj vXPermObj = new VXPermObj();
@@ -348,13 +485,11 @@ public class TestPublicAPIs extends BaseTest {
 		vXPolicyHBase.setColumnFamilies("invoices,emps," + GUIDUtil.genGUI());
 		vXPolicyHBase.setColumns("amt, emp_id, " + GUIDUtil.genGUI());
 		vXPolicyHBase.setDescription("home policy for HBase");
-		// vXPolicyHBase.setRepositoryName("hadoopdev");
+		vXPolicyHBase.setRepositoryName(vXRepoHBase.getName());
 		vXPolicyHBase.setRepositoryType("HBase");
 		vXPolicyHBase.setEnabled(true);
 		vXPolicyHBase.setRecursive(true);
 		vXPolicyHBase.setAuditEnabled(true);
-		vXPolicyHBase.setRepositoryId(vXRepoHBase.getId());
-		vXPolicyHBase.setResourceType("Column");
 
 		VXPermObj vXPermObj = new VXPermObj();
 		List<String> userList = new ArrayList<String>();
@@ -395,12 +530,11 @@ public class TestPublicAPIs extends BaseTest {
 		vXPolicyHDFS.setPolicyName("HomePolicy_" + GUIDUtil.genGUI());
 		vXPolicyHDFS.setResourceName("/home,/apps,/" + GUIDUtil.genGUI());
 		vXPolicyHDFS.setDescription("home policy for HDFS");
-		// vXPolicyHDFS.setRepositoryName("hadoopdev");
+		vXPolicyHDFS.setRepositoryName(vXRepoHDFS.getName());
 		vXPolicyHDFS.setRepositoryType("hdfs");
 		vXPolicyHDFS.setEnabled(true);
 		vXPolicyHDFS.setRecursive(true);
 		vXPolicyHDFS.setAuditEnabled(true);
-		vXPolicyHDFS.setRepositoryId(vXRepoHDFS.getId());
 
 		VXPermObj vXPermObj = new VXPermObj();
 		List<String> userList = new ArrayList<String>();
@@ -448,7 +582,8 @@ public class TestPublicAPIs extends BaseTest {
 		vXPolicyHDFS.setPolicyName("HDFS Policy Updated_" + GUIDUtil.genGUI());
 		vXPolicyHDFS.setRecursive(false);
 		vXPolicyHDFS.setPermMapList(vXPolicyHive.getPermMapList());
-		vXPolicyHDFS = publicAPIs.updatePolicy(vXPolicyHDFS);
+		vXPolicyHDFS = publicAPIs.updatePolicy(vXPolicyHDFS,
+				vXPolicyHDFS.getId());
 
 		assertNotNull("Error While updating Policy", vXPolicyHDFS);
 		logger.info("Update : Policy for HDFS updated Successfully");
@@ -457,7 +592,8 @@ public class TestPublicAPIs extends BaseTest {
 		vXPolicyHBase
 				.setPolicyName("HBase Policy Updated_" + GUIDUtil.genGUI());
 		vXPolicyHBase.setEnabled(false);
-		vXPolicyHBase = publicAPIs.updatePolicy(vXPolicyHBase);
+		vXPolicyHBase = publicAPIs.updatePolicy(vXPolicyHBase,
+				vXPolicyHBase.getId());
 
 		assertNotNull("Error While updating Policy", vXPolicyHBase);
 		logger.info("Update : Policy for HBase updated Successfully");
@@ -466,10 +602,32 @@ public class TestPublicAPIs extends BaseTest {
 		vXPolicyHive.setPolicyName("Hive Policy Updated_" + GUIDUtil.genGUI());
 		vXPolicyHive.setAuditEnabled(false);
 		vXPolicyHive.setPermMapList(null);
-		vXPolicyHive = publicAPIs.updatePolicy(vXPolicyHive);
+		vXPolicyHive = publicAPIs.updatePolicy(vXPolicyHive,
+				vXPolicyHive.getId());
 
 		assertNotNull("Error While updating Policy", vXPolicyHive);
 		logger.info("Update : Policy for Hive updated Successfully");
+
+		// Update Knox Policy
+		vXPolicyKnox.setPolicyName("Knox Policy Updated_" + GUIDUtil.genGUI());
+		vXPolicyKnox.setAuditEnabled(false);
+		vXPolicyKnox.setPermMapList(null);
+		vXPolicyKnox = publicAPIs.updatePolicy(vXPolicyKnox,
+				vXPolicyKnox.getId());
+
+		assertNotNull("Error While updating Policy", vXPolicyStorm);
+		logger.info("Update : Policy for Hive updated Successfully");
+
+		// Update Storm Policy
+		vXPolicyStorm
+				.setPolicyName("Storm Policy Updated_" + GUIDUtil.genGUI());
+		vXPolicyStorm.setAuditEnabled(false);
+		vXPolicyStorm.setPermMapList(null);
+		vXPolicyStorm = publicAPIs.updatePolicy(vXPolicyStorm,
+				vXPolicyStorm.getId());
+
+		assertNotNull("Error While updating Policy", vXPolicyStorm);
+		logger.info("Update : Policy for Hive updated Successfully");
 	}
 
 	/**


Mime
View raw message