ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sneet...@apache.org
Subject [1/2] git commit: ARGUS-54:Fixed Delete Repo REST API
Date Tue, 16 Sep 2014 15:44:06 GMT
Repository: incubator-argus
Updated Branches:
  refs/heads/master 57c364586 -> a4ec210ed


ARGUS-54:Fixed Delete Repo REST API

Signed-off-by: sneethiraj <sneethir@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/0ee4b9b2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-argus/tree/0ee4b9b2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-argus/diff/0ee4b9b2

Branch: refs/heads/master
Commit: 0ee4b9b2f7d0d5e6d0156faa53595b4d1b588d93
Parents: 57c3645
Author: vperiasamy <vperiasamy@hortonworks.com>
Authored: Tue Sep 16 10:01:33 2014 -0400
Committer: sneethiraj <sneethir@apache.org>
Committed: Tue Sep 16 11:35:09 2014 -0400

----------------------------------------------------------------------
 .../main/java/com/xasecure/biz/AssetMgr.java    | 57 +++++++++++++++++---
 .../main/java/com/xasecure/rest/AssetREST.java  | 10 ++++
 .../xasecure/service/XRepositoryService.java    | 15 ++++--
 3 files changed, 72 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/0ee4b9b2/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 dfed3b9..7c46ac9 100644
--- a/security-admin/src/main/java/com/xasecure/biz/AssetMgr.java
+++ b/security-admin/src/main/java/com/xasecure/biz/AssetMgr.java
@@ -315,7 +315,7 @@ public class AssetMgr extends AssetMgrBase {
 					MessageEnums.INVALID_INPUT_DATA);
 		}
 		
-		if(xAsset.getActiveStatus()==XACommonEnums.ACT_STATUS_DISABLED){
+		if(xAsset.getActiveStatus()==XACommonEnums.STATUS_DISABLED){
 			if(!currentUserSession.isUserAdmin()){
 				logger.error("Trying to update policy in disabled repository");
 				throw restErrorUtil.createRESTException("Resource "
@@ -624,8 +624,8 @@ public class AssetMgr extends AssetMgrBase {
 					+ "you're deleting policy, doesn't exist.",
 					MessageEnums.INVALID_INPUT_DATA);
 		}
-		
-		if(xAsset.getActiveStatus()==XACommonEnums.ACT_STATUS_DISABLED){
+
+		if(xAsset.getActiveStatus()==XACommonEnums.STATUS_DISABLED){
 			if(!currentUserSession.isUserAdmin()){
 				logger.error("Trying to delete policy in disabled repository");
 				throw restErrorUtil.createRESTException("Resource "
@@ -1161,11 +1161,13 @@ public class AssetMgr extends AssetMgrBase {
 							finalTableName = tableName;
 							finalDbName = databaseName;
 							callableObj = new Callable<List<String>>() {
+
 								@Override
 								public List<String> call() {
 									return hiveClient.getTableList(finalDbName,
 											finalTableName);
 								}
+							
 							};
 						}
 					} else {
@@ -1335,6 +1337,15 @@ public class AssetMgr extends AssetMgrBase {
 		if (usb != null && usb.isUserAdmin()) {
 			XXAsset xAsset = xADaoManager.getXXAsset()
 					.getById(vXAsset.getId());
+			
+			if (xAsset.getActiveStatus() == XACommonEnums.STATUS_DELETED) {
+				logger.error("Trying to update Asset which is soft deleted");
+				throw restErrorUtil.createRESTException(
+						"Repository that you want to update does not exist.",
+						MessageEnums.DATA_NOT_FOUND, xAsset.getId(), null,
+						"Repository not exist for this Id : " + xAsset.getId());
+			}
+			
 			List<XXTrxLog> trxLogList = xAssetService.getTransactionLog(
 					vXAsset, xAsset, "update");
 			vXAsset = (VXAsset) xAssetService.updateResource(vXAsset);
@@ -1357,6 +1368,15 @@ public class AssetMgr extends AssetMgrBase {
 		UserSessionBase usb = ContextUtil.getCurrentUserSession();
 		if (usb != null && usb.isUserAdmin() && force) {
 			VXAsset vxAsset = xAssetService.readResource(id);
+			
+			if (vxAsset.getActiveStatus() == XACommonEnums.STATUS_DELETED) {
+				logger.error("Trying to delete Asset which is already soft deleted");
+				throw restErrorUtil.createRESTException(
+						"Repository not found or its already deleted, for Id : "
+								+ id, MessageEnums.DATA_NOT_FOUND, id, null,
+						"Repository not exist for this Id : " + id);
+			}
+			
 			SearchCriteria searchCriteria = new SearchCriteria();
 			searchCriteria.addParam("assetId", id);
 			VXResourceList resources = searchXResources(searchCriteria);
@@ -1518,6 +1538,15 @@ public class AssetMgr extends AssetMgrBase {
 	}
 
 	public VXResponse testConfig(VXAsset vXAsset) {
+		
+		if (vXAsset.getActiveStatus() == XACommonEnums.STATUS_DELETED) {
+			logger.error("Trying to test Asset which is soft deleted");
+			throw restErrorUtil.createRESTException(
+					"Repository not found, Repository Name : " + vXAsset.getName(),
+					MessageEnums.DATA_NOT_FOUND, vXAsset.getId(), null,
+					"Repository not exist for this Id : " + vXAsset.getId());
+		}
+		
 		int assetType = vXAsset.getAssetType();
 		VXResponse testResponse = new VXResponse();
 		boolean connectivityStatus = false;
@@ -2239,9 +2268,25 @@ public class AssetMgr extends AssetMgrBase {
 				.getCurrentUserSession();
 		VXAsset vXAsset=null;
 		if (currentUserSession.isUserAdmin()) {
-			return (VXAsset)xAssetService.readResource(id);			
+			vXAsset = xAssetService.readResource(id);
+			if (vXAsset.getActiveStatus() == XACommonEnums.STATUS_DELETED) {
+				logger.error("Trying to read Asset which is soft deleted");
+				throw restErrorUtil.createRESTException(
+						"Repository not found for this Id : " + id,
+						MessageEnums.DATA_NOT_FOUND, id, null,
+						"Repository does not exist for this Id : " + id);
+			}
 		}else{			
-			XXAsset  xXAsset=xADaoManager.getXXAsset().getById(id);		
+			XXAsset  xXAsset=xADaoManager.getXXAsset().getById(id);	
+			
+			if (xXAsset.getActiveStatus() == XACommonEnums.STATUS_DELETED) {
+				logger.error("Trying to read Asset which is soft deleted");
+				throw restErrorUtil.createRESTException(
+						"Repository not found for this Id : " + id,
+						MessageEnums.DATA_NOT_FOUND, id, null,
+						"Repository does not exist for this Id : " + id);
+			}
+			
 			vXAsset=xAssetService.populateViewBean(xXAsset);
 			/*List<XXResource>  xXResourceList=xADaoManager
 					.getXXResource().findByAssetId(id);
@@ -3062,5 +3107,5 @@ public class AssetMgr extends AssetMgrBase {
         List<String> toplogyList = stormClient.getTopologyList(topologyName) ;
         return msBizUtil.mapStringListToVStringList(toplogyList) ;
     }
-
+    
 }

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/0ee4b9b2/security-admin/src/main/java/com/xasecure/rest/AssetREST.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/rest/AssetREST.java b/security-admin/src/main/java/com/xasecure/rest/AssetREST.java
index 0096285..1453ef9 100644
--- a/security-admin/src/main/java/com/xasecure/rest/AssetREST.java
+++ b/security-admin/src/main/java/com/xasecure/rest/AssetREST.java
@@ -191,6 +191,16 @@ public class AssetREST {
 	public VXLong countXAssets(@Context HttpServletRequest request) {
 		SearchCriteria searchCriteria = searchUtil.extractCommonCriterias(
 				request, xAssetService.sortFields);
+		
+		searchUtil.extractIntList(request, searchCriteria, "status", "status",
+				"status");
+		Object status = searchCriteria.getParamValue("status");
+		if (status == null || ((Collection) status).size() == 0) {
+			ArrayList<Integer> valueList = new ArrayList<Integer>();
+			valueList.add(XACommonEnums.STATUS_DISABLED);
+			valueList.add(XACommonEnums.STATUS_ENABLED);
+			searchCriteria.addParam("status", valueList);
+		}
 		return assetMgr.getXAssetSearchCount(searchCriteria);
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/0ee4b9b2/security-admin/src/main/java/com/xasecure/service/XRepositoryService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/service/XRepositoryService.java b/security-admin/src/main/java/com/xasecure/service/XRepositoryService.java
index 98c5b43..645da1d 100644
--- a/security-admin/src/main/java/com/xasecure/service/XRepositoryService.java
+++ b/security-admin/src/main/java/com/xasecure/service/XRepositoryService.java
@@ -68,8 +68,12 @@ public class XRepositoryService extends
 		vRepo.setRepositoryType(AppConstants.getLabelFor_AssetType(vXAsset
 				.getAssetType()));
 		vRepo.setConfig(vXAsset.getConfig());
-		vRepo.setIsActive(AppConstants.getBooleanFor_BooleanValue(vXAsset
-				.getActiveStatus()));
+		
+		int actStatus = vXAsset.getActiveStatus();
+		boolean isAct = (actStatus == XACommonEnums.STATUS_DISABLED) ? false
+				: true;
+
+		vRepo.setIsActive(isAct);
 		vRepo.setVersion(version);
 
 		return vRepo;
@@ -85,8 +89,11 @@ public class XRepositoryService extends
 		vXAsset.setAssetType(AppConstants.getEnumFor_AssetType(vXRepo
 				.getRepositoryType()));
 		vXAsset.setConfig(vXRepo.getConfig());
-		vXAsset.setActiveStatus(AppConstants.getEnumFor_BooleanValue(vXRepo
-				.getIsActive()));
+		
+		int actStatus = (!vXRepo.getIsActive()) ? XACommonEnums.STATUS_DISABLED
+				: XACommonEnums.STATUS_ENABLED;
+
+		vXAsset.setActiveStatus(actStatus);
 
 		return vXAsset;
 	}


Mime
View raw message