ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From v..@apache.org
Subject incubator-ranger git commit: RANGER-403 : Minor modifications to Public API with respect to RANGER-403
Date Thu, 23 Apr 2015 09:41:11 GMT
Repository: incubator-ranger
Updated Branches:
  refs/heads/master b05edbc8d -> 353ce61c9


RANGER-403 : Minor modifications to Public API with respect to RANGER-403

Signed-off-by: Velmurugan Periasamy <vel@apache.org>


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

Branch: refs/heads/master
Commit: 353ce61c9b3a08dbf4c476f37ebb214caed3ece7
Parents: b05edbc
Author: Gautam Borad <gborad@gmail.com>
Authored: Wed Apr 22 15:53:16 2015 +0530
Committer: Velmurugan Periasamy <vel@apache.org>
Committed: Thu Apr 23 05:40:51 2015 -0400

----------------------------------------------------------------------
 .../java/org/apache/ranger/rest/PublicAPIs.java | 28 ++++++++++++++------
 1 file changed, 20 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/353ce61c/security-admin/src/main/java/org/apache/ranger/rest/PublicAPIs.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/rest/PublicAPIs.java b/security-admin/src/main/java/org/apache/ranger/rest/PublicAPIs.java
index 736e56f..34ac345 100644
--- a/security-admin/src/main/java/org/apache/ranger/rest/PublicAPIs.java
+++ b/security-admin/src/main/java/org/apache/ranger/rest/PublicAPIs.java
@@ -19,11 +19,13 @@
 
 package org.apache.ranger.rest;
 
-import org.apache.commons.collections.MapUtils;
 import org.apache.log4j.Logger;
 import org.apache.ranger.common.*;
 import org.apache.ranger.common.annotation.RangerAnnotationClassName;
 import org.apache.ranger.common.annotation.RangerAnnotationJSMgrName;
+import org.apache.ranger.db.RangerDaoManager;
+import org.apache.ranger.entity.XXPolicy;
+import org.apache.ranger.entity.XXService;
 import org.apache.ranger.plugin.model.RangerPolicy;
 import org.apache.ranger.plugin.model.RangerService;
 import org.apache.ranger.plugin.util.SearchFilter;
@@ -41,7 +43,6 @@ import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.*;
 import javax.ws.rs.core.Context;
 
-import java.util.HashMap;
 import java.util.List;
 
 @Path("public")
@@ -70,6 +71,11 @@ public class PublicAPIs {
 	@Autowired
 	ServiceREST serviceREST;
 
+	@Autowired
+	RangerDaoManager daoMgr;
+
+	@Autowired
+	RESTErrorUtil restErrorUtil;
 	
 	@GET
 	@Path("/api/repository/{id}")
@@ -126,11 +132,17 @@ public class PublicAPIs {
 			logger.debug("==> PublicAPIs.updateRepository(" + id + ")");
 		}
 		
+		XXService existing = daoMgr.getXXService().getById(id);
+		if(existing == null) {
+			throw restErrorUtil.createRESTException("Repository not found for Id: " + id, MessageEnums.DATA_NOT_FOUND);
+		}
+
 		vXRepository.setId(id);
 		
 		VXAsset vXAsset  = serviceUtil.publicObjecttoVXAsset(vXRepository);
 
 		RangerService service = serviceUtil.toRangerService(vXAsset);
+		service.setVersion(existing.getVersion());
 
 		RangerService updatedService = serviceREST.updateService(service);
 		
@@ -157,12 +169,6 @@ public class PublicAPIs {
 			logger.debug("==> PublicAPIs.deleteRepository(" + id + ")");
 		}
 		
-		String forceStr = request.getParameter("force");
-		boolean force = true;
-		if (!stringUtil.isEmpty(forceStr)) {
-			force = Boolean.parseBoolean(forceStr.trim());
-		}
-				
 		serviceREST.deleteService(id);
 		
 		if(logger.isDebugEnabled()) {
@@ -285,11 +291,17 @@ public class PublicAPIs {
 			logger.debug("==> PublicAPIs.updatePolicy(): "  + vXPolicy );
 		}
 		
+		XXPolicy existing = daoMgr.getXXPolicy().getById(id);
+		if(existing == null) {
+			throw restErrorUtil.createRESTException("Policy not found for Id: " + id, MessageEnums.DATA_NOT_FOUND);
+		}
+
 		vXPolicy.setId(id);
 		
 		RangerService service       = serviceREST.getServiceByName(vXPolicy.getRepositoryName());
 		
 		RangerPolicy  policy        = serviceUtil.toRangerPolicy(vXPolicy,service);
+		policy.setVersion(existing.getVersion());
 
 		RangerPolicy  updatedPolicy = serviceREST.updatePolicy(policy);
 


Mime
View raw message