You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by sn...@apache.org on 2014/10/08 05:12:58 UTC
git commit: ARGUS-103:Fixed review comments for Policy already exists
error when saving Hive policy
Repository: incubator-argus
Updated Branches:
refs/heads/master 500edcff6 -> cd7e677ae
ARGUS-103:Fixed review comments for Policy already exists error when saving Hive policy
Signed-off-by: sneethiraj <sn...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-argus/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-argus/commit/cd7e677a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-argus/tree/cd7e677a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-argus/diff/cd7e677a
Branch: refs/heads/master
Commit: cd7e677aee3c8185ce6f3d3953144e97c55a4d2f
Parents: 500edcf
Author: vperiasamy <vp...@hortonworks.com>
Authored: Tue Oct 7 16:01:12 2014 -0400
Committer: sneethiraj <sn...@apache.org>
Committed: Tue Oct 7 23:12:34 2014 -0400
----------------------------------------------------------------------
.../main/java/com/xasecure/biz/AssetMgr.java | 42 ++++++++++++--------
1 file changed, 25 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/cd7e677a/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 cbf7017..10d3d4d 100644
--- a/security-admin/src/main/java/com/xasecure/biz/AssetMgr.java
+++ b/security-admin/src/main/java/com/xasecure/biz/AssetMgr.java
@@ -359,11 +359,13 @@ public class AssetMgr extends AssetMgrBase {
VXResourceList vXResourceList=xResourceService.searchXResourcesWithoutLogin(searchCriteria);
if(vXResourceList!=null && vXResourceList.getListSize()>0){
- for(VXResource vXResourceTemp :vXResourceList.getList()){
- if(vXResourceTemp.getId()!=vXResource.getId()){
- logger.error("policy already exist with name "+vXResource.getName());
- throw restErrorUtil.createRESTException("policy already exist with name "
- +vXResource.getName(),MessageEnums.ERROR_DUPLICATE_OBJECT);
+ if(vXResource!=null && vXResource.getId()!=null){
+ for(VXResource vXResourceTemp :vXResourceList.getList()){
+ if(vXResourceTemp!=null && !(vXResource.getId().equals(vXResourceTemp.getId()))){
+ logger.error("policy already exists with name "+vXResource.getName());
+ throw restErrorUtil.createRESTException("policy already exists with name "
+ +vXResource.getName(),MessageEnums.ERROR_DUPLICATE_OBJECT);
+ }
}
}
}
@@ -385,14 +387,18 @@ public class AssetMgr extends AssetMgrBase {
searchCriteria.getParamList().put("fullPolicyName", vXResource.getPolicyName());
vXResourceList=xResourceService.searchXResourcesWithoutLogin(searchCriteria);
if(vXResourceList!=null && vXResourceList.getListSize()>0){
- for (VXResource newVXResource : vXResourceList.getList()) {
- if(vXResource.getId()!=newVXResource.getId() && vXResource.getPolicyName().trim().equalsIgnoreCase(newVXResource.getPolicyName().trim())){
- logger.error("policy already exist with name "+vXResource.getPolicyName());
- logger.info("A system generated policy name shall be assigned to "+vXResource.getPolicyName());
-// vXResource.setPolicyName(null);
-// break;
- throw restErrorUtil.createRESTException("policy already exist with name "
- +vXResource.getPolicyName(),MessageEnums.ERROR_DUPLICATE_OBJECT);
+ if(vXResource!=null && vXResource.getId()!=null){
+ for (VXResource newVXResource : vXResourceList.getList()) {
+ if(newVXResource!=null && newVXResource.getId()!=null){
+ if(!vXResource.getId().equals(newVXResource.getId()) && vXResource.getPolicyName().trim().equalsIgnoreCase((newVXResource.getPolicyName()!=null?newVXResource.getPolicyName().trim():newVXResource.getPolicyName()))){
+ logger.error("policy already exists with name "+vXResource.getPolicyName());
+// logger.info("A system generated policy name shall be assigned to "+vXResource.getPolicyName());
+// vXResource.setPolicyName(null);
+// break;
+ throw restErrorUtil.createRESTException("policy already exists with name "
+ +vXResource.getPolicyName(),MessageEnums.ERROR_DUPLICATE_OBJECT);
+ }
+ }
}
}
}
@@ -402,16 +408,18 @@ public class AssetMgr extends AssetMgrBase {
int totalPoliciesCount=1;
String tempPolicyName=null;
vXResourceList=null;
- if(vXResource.getPolicyName()==null ||vXResource.getPolicyName().trim().isEmpty()){
+ if(vXResource!=null && (vXResource.getPolicyName()==null ||vXResource.getPolicyName().trim().isEmpty())){
searchCriteria=new SearchCriteria();
searchCriteria.getParamList().put("assetId", vXResource.getAssetId());
vXResourceList=xResourceService.searchXResourcesWithoutLogin(searchCriteria);
if(vXResourceList!=null && vXResourceList.getListSize()>0){
totalPoliciesCount=vXResourceList.getListSize();
tempPoliciesCount++;
- for(VXResource newVXResource : vXResourceList.getList()) {
- if(vXResource.getId()==newVXResource.getId()){
- break;
+ for(VXResource newVXResource : vXResourceList.getList()) {
+ if(newVXResource!=null && newVXResource.getId()!=null){
+ if(vXResource.getId().equals(newVXResource.getId())){
+ break;
+ }
}
tempPoliciesCount++;
}