Ranger-203 : Add pluggable logic to UI code
Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/9d85cb76 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/9d85cb76 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/9d85cb76 Branch: refs/heads/stack Commit: 9d85cb76a05f1e1bf57039047dc710b1034c059e Parents: 418b0fa Author: Gautam Borad <[email protected]> Authored: Mon Jan 5 23:45:09 2015 -0800 Committer: Madhan Neethiraj <[email protected]> Committed: Wed Jan 7 11:18:37 2015 -0800 ---------------------------------------------------------------------- security-admin/pom.xml | 5 - .../java/org/apache/ranger/rest/AssetREST.java | 376 ++++++----- .../org/apache/ranger/rest/ServiceREST.java | 5 +- .../collection_bases/RangerPolicyListBase.js | 66 ++ .../RangerPolicyResourceListBase.js | 66 ++ .../RangerServiceDefListBase.js | 70 +++ .../collection_bases/RangerServiceListBase.js | 66 ++ .../scripts/collections/RangerPolicyList.js | 34 + .../collections/RangerPolicyResourceList.js | 34 + .../scripts/collections/RangerServiceDefList.js | 36 ++ .../scripts/collections/RangerServiceList.js | 36 ++ .../webapp/scripts/controllers/Controller.js | 137 +++- .../scripts/model_bases/RangerPolicyBase.js | 90 +++ .../model_bases/RangerPolicyResourceBase.js | 90 +++ .../scripts/model_bases/RangerServiceBase.js | 90 +++ .../scripts/model_bases/RangerServiceDefBase.js | 105 ++++ .../main/webapp/scripts/models/RangerPolicy.js | 107 ++++ .../scripts/models/RangerPolicyResource.js | 71 +++ .../main/webapp/scripts/models/RangerService.js | 72 +++ .../webapp/scripts/models/RangerServiceDef.js | 95 +++ .../src/main/webapp/scripts/modules/XALinks.js | 28 +- .../main/webapp/scripts/modules/XAOverrides.js | 2 +- .../src/main/webapp/scripts/routers/Router.js | 16 +- .../src/main/webapp/scripts/utils/XAEnums.js | 11 +- .../src/main/webapp/scripts/utils/XAUtils.js | 71 +-- .../scripts/views/policies/GroupPermList.js | 429 +++++++++++++ .../views/policies/RangerPolicyCreate.js | 322 ++++++++++ .../scripts/views/policies/RangerPolicyForm.js | 617 +++++++++++++++++++ .../views/policies/RangerPolicyTableLayout.js | 388 ++++++++++++ .../scripts/views/policies/UserPermList.js | 430 +++++++++++++ .../views/policymanager/ServiceLayout.js | 106 ++++ .../scripts/views/service/ServiceCreate.js | 285 +++++++++ .../webapp/scripts/views/service/ServiceForm.js | 189 ++++++ .../scripts/views/service/ServiceTableLayout.js | 164 +++++ security-admin/src/main/webapp/styles/xa.css | 15 + .../common/ServiceManagerLayout_tmpl.html | 67 ++ .../templates/common/UserPermissionItem.html | 2 +- .../main/webapp/templates/helpers/XAHelpers.js | 30 + .../templates/policies/GroupPermItem.html | 54 ++ .../templates/policies/GroupPermList.html | 42 ++ .../policies/RangerPolicyForm_tmpl.html | 59 ++ .../policies/RangerPolicyTableLayout_tmpl.html | 30 + .../webapp/templates/policies/UserPermItem.html | 51 ++ .../webapp/templates/policies/UserPermList.html | 42 ++ .../templates/service/ServiceCreate_tmpl.html | 36 ++ .../templates/service/ServiceForm_tmpl.html | 46 ++ .../service/ServiceTableLayout_tmpl.html | 29 + 47 files changed, 4993 insertions(+), 219 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/pom.xml ---------------------------------------------------------------------- diff --git a/security-admin/pom.xml b/security-admin/pom.xml index 264c53d..d602b47 100644 --- a/security-admin/pom.xml +++ b/security-admin/pom.xml @@ -413,11 +413,6 @@ <scope>runtime</scope> </dependency> <dependency> - <groupId>cn.guoyukun.jdbc</groupId> - <artifactId>oracle-ojdbc6</artifactId> - <version>11.2.0.3.0</version> - </dependency> - <dependency> <groupId>org.apache.ranger</groupId> <artifactId>plugin-common</artifactId> <version>0.4.0</version> http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/java/org/apache/ranger/rest/AssetREST.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/rest/AssetREST.java b/security-admin/src/main/java/org/apache/ranger/rest/AssetREST.java index 27c3119..f160382 100644 --- a/security-admin/src/main/java/org/apache/ranger/rest/AssetREST.java +++ b/security-admin/src/main/java/org/apache/ranger/rest/AssetREST.java @@ -22,7 +22,7 @@ import java.io.File; import java.security.cert.X509Certificate; import java.util.ArrayList; -import java.util.Collection; +import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.DELETE; @@ -42,10 +42,12 @@ import org.apache.ranger.biz.AssetMgr; import org.apache.ranger.biz.RangerBizUtil; import org.apache.ranger.common.PropertiesUtil; import org.apache.ranger.common.RESTErrorUtil; -import org.apache.ranger.common.RangerCommonEnums; import org.apache.ranger.common.RangerSearchUtil; import org.apache.ranger.common.SearchCriteria; +import org.apache.ranger.common.ServiceUtil; import org.apache.ranger.common.StringUtil; +import org.apache.ranger.plugin.model.RangerPolicy; +import org.apache.ranger.plugin.model.RangerService; import org.apache.ranger.common.annotation.RangerAnnotationClassName; import org.apache.ranger.common.annotation.RangerAnnotationJSMgrName; import org.apache.ranger.service.AbstractBaseResourceService; @@ -120,26 +122,73 @@ public class AssetREST { @Autowired XAccessAuditService xAccessAuditService; - + + @Autowired + ServiceUtil serviceUtil; + + @Autowired + ServiceREST serviceREST; + + @GET @Path("/assets/{id}") @Produces({ "application/xml", "application/json" }) public VXAsset getXAsset(@PathParam("id") Long id) { - return assetMgr.getXAsset(id); + if(logger.isDebugEnabled()) { + logger.debug("==> AssetREST.getXAsset(" + id + ")"); + } + + RangerService service = serviceREST.getService(id); + + VXAsset ret = serviceUtil.toVXAsset(service); + + if(logger.isDebugEnabled()) { + logger.debug("<== AssetREST.getXAsset(" + id + "): " + ret); + } + + return ret; } @POST @Path("/assets") @Produces({ "application/xml", "application/json" }) public VXAsset createXAsset(VXAsset vXAsset) { - return assetMgr.createXAsset(vXAsset); + if(logger.isDebugEnabled()) { + logger.debug("==> AssetREST.createXAsset(" + vXAsset + ")"); + } + + RangerService service = serviceUtil.toRangerService(vXAsset); + + RangerService createdService = serviceREST.createService(service); + + VXAsset ret = serviceUtil.toVXAsset(createdService); + + if(logger.isDebugEnabled()) { + logger.debug("<== AssetREST.createXAsset(" + vXAsset + "): " + ret); + } + + return ret; } @PUT @Path("/assets/{id}") @Produces({ "application/xml", "application/json" }) public VXAsset updateXAsset(VXAsset vXAsset) { - return assetMgr.updateXAsset(vXAsset); + if(logger.isDebugEnabled()) { + logger.debug("==> AssetREST.updateXAsset(" + vXAsset + ")"); + } + + RangerService service = serviceUtil.toRangerService(vXAsset); + + RangerService updatedService = serviceREST.updateService(service); + + VXAsset ret = serviceUtil.toVXAsset(updatedService); + + if(logger.isDebugEnabled()) { + logger.debug("<== AssetREST.updateXAsset(" + vXAsset + "): " + ret); + } + + return ret; } @DELETE @@ -148,79 +197,154 @@ public class AssetREST { @RangerAnnotationClassName(class_name = VXAsset.class) public void deleteXAsset(@PathParam("id") Long id, @Context HttpServletRequest request) { - boolean force = true; - assetMgr.deleteXAsset(id, force); + if(logger.isDebugEnabled()) { + logger.debug("==> AssetREST.deleteXAsset(" + id + ")"); + } + + serviceREST.deleteService(id); + + if(logger.isDebugEnabled()) { + logger.debug("<== AssetREST.deleteXAsset(" + id + ")"); + } } @POST @Path("/assets/testConfig") @Produces({ "application/xml", "application/json" }) public VXResponse testConfig(VXAsset vXAsset) { - return assetMgr.testConfig(vXAsset); + if(logger.isDebugEnabled()) { + logger.debug("==> AssetREST.testConfig(" + vXAsset + ")"); + } + + RangerService service = serviceUtil.toRangerService(vXAsset); + + VXResponse ret = serviceREST.validateConfig(service); + + if(logger.isDebugEnabled()) { + logger.debug("<== AssetREST.testConfig(" + vXAsset + "): " + ret); + } + + return ret; } @GET @Path("/assets") @Produces({ "application/xml", "application/json" }) - @SuppressWarnings("rawtypes") public VXAssetList searchXAssets(@Context HttpServletRequest request) { - SearchCriteria searchCriteria = searchUtil.extractCommonCriterias( - request, xAssetService.sortFields); - - searchUtil.extractIntList(request, searchCriteria, "status", "status", - "status"); - // searchUtil.extractStringList(request, searchCriteria, "status", - // "status", "status", null, StringUtil.VALIDATION_TEXT); - Object status = searchCriteria.getParamValue("status"); - if (status == null || ((Collection) status).size() == 0) { - ArrayList<Integer> valueList = new ArrayList<Integer>(); - valueList.add(RangerCommonEnums.STATUS_DISABLED); - valueList.add(RangerCommonEnums.STATUS_ENABLED); - searchCriteria.addParam("status", valueList); - } - return assetMgr.searchXAssets(searchCriteria); + if(logger.isDebugEnabled()) { + logger.debug("==> AssetREST.searchXAssets()"); + } + + VXAssetList ret = new VXAssetList(); + + List<RangerService> services = serviceREST.getServices(request); + + if(services != null) { + List<VXAsset> assets = new ArrayList<VXAsset>(services.size()); + + for(RangerService service : services) { + assets.add(serviceUtil.toVXAsset(service)); + } + + ret.setVXAssets(assets); + } + + if(logger.isDebugEnabled()) { + logger.debug("<== AssetREST.searchXAssets(): count=" + (ret == null ? 0 : ret.getListSize())); + } + + return ret; } @GET @Path("/assets/count") @Produces({ "application/xml", "application/json" }) 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(RangerCommonEnums.STATUS_DISABLED); - valueList.add(RangerCommonEnums.STATUS_ENABLED); - searchCriteria.addParam("status", valueList); - } - return assetMgr.getXAssetSearchCount(searchCriteria); + if(logger.isDebugEnabled()) { + logger.debug("==> AssetREST.countXAssets()"); + } + + VXLong ret = new VXLong(); + + Long svcCount = serviceREST.countServices(request); + + ret.setValue(svcCount == null ? 0 : svcCount.longValue()); + + if(logger.isDebugEnabled()) { + logger.debug("<== AssetREST.countXAssets(): " + ret); + } + + return ret; } @GET @Path("/resources/{id}") @Produces({ "application/xml", "application/json" }) public VXResource getXResource(@PathParam("id") Long id) { - return assetMgr.getXResource(id); + if(logger.isDebugEnabled()) { + logger.debug("==> AssetREST.getXResource(" + id + ")"); + } + + RangerPolicy policy = null; + RangerService service = null; + + policy = serviceREST.getPolicy(id); + + if(policy != null) { + service = serviceREST.getServiceByName(policy.getService()); + } + + VXResource ret = serviceUtil.toVXResource(policy, service); + + if(logger.isDebugEnabled()) { + logger.debug("<== AssetREST.getXResource(" + id + "): " + ret); + } + + return ret; } @POST @Path("/resources") @Produces({ "application/xml", "application/json" }) public VXResource createXResource(VXResource vXResource) { - vXResource=assetMgr.createXResource(vXResource); - return vXResource; - + if(logger.isDebugEnabled()) { + logger.debug("==> AssetREST.createXResource(" + vXResource + ")"); + } + + RangerService service = serviceREST.getService(vXResource.getAssetId()); + RangerPolicy policy = serviceUtil.toRangerPolicy(vXResource, service); + + RangerPolicy createdPolicy = serviceREST.createPolicy(policy); + + VXResource ret = serviceUtil.toVXResource(createdPolicy, service); + + if(logger.isDebugEnabled()) { + logger.debug("<== AssetREST.createXResource(" + vXResource + "): " + ret); + } + + return ret; } @PUT @Path("/resources/{id}") @Produces({ "application/xml", "application/json" }) public VXResource updateXResource(VXResource vXResource) { - return assetMgr.updateXResource(vXResource); + if(logger.isDebugEnabled()) { + logger.debug("==> AssetREST.updateXResource(" + vXResource + ")"); + } + + RangerService service = serviceREST.getService(vXResource.getAssetId()); + RangerPolicy policy = serviceUtil.toRangerPolicy(vXResource, service); + + RangerPolicy updatedPolicy = serviceREST.updatePolicy(policy); + + VXResource ret = serviceUtil.toVXResource(updatedPolicy, service); + + if(logger.isDebugEnabled()) { + logger.debug("<== AssetREST.updateXResource(" + vXResource + "): " + ret); + } + + return ret; } @DELETE @@ -229,110 +353,70 @@ public class AssetREST { @RangerAnnotationClassName(class_name = VXResource.class) public void deleteXResource(@PathParam("id") Long id, @Context HttpServletRequest request) { - boolean force = false; - assetMgr.deleteXResource(id, force); + if(logger.isDebugEnabled()) { + logger.debug("==> AssetREST.deleteXResource(" + id + ")"); + } + + serviceREST.deletePolicy(id); + + if(logger.isDebugEnabled()) { + logger.debug("<== AssetREST.deleteXResource(" + id + ")"); + } } @GET @Path("/resources") @Produces({ "application/xml", "application/json" }) public VXResourceList searchXResources(@Context HttpServletRequest request) { - SearchCriteria searchCriteria = searchUtil.extractCommonCriterias( - request, xResourceService.sortFields); - // searchUtil.extractStringList(request, searchCriteria, "name", "Name", - // "name", null, StringUtil.VALIDATION_TEXT); - - searchUtil.extractString(request, searchCriteria, "name", - "Resource Path", StringUtil.VALIDATION_TEXT); - searchUtil.extractString(request, searchCriteria, "policyName", - "Policy name", StringUtil.VALIDATION_TEXT); - searchUtil.extractString(request, searchCriteria, "columns", - "Column name", StringUtil.VALIDATION_TEXT); - searchUtil.extractString(request, searchCriteria, "columnFamilies", - "Column Family", StringUtil.VALIDATION_TEXT); - searchUtil.extractString(request, searchCriteria, "tables", - "Tables", StringUtil.VALIDATION_TEXT); - searchUtil.extractString(request, searchCriteria, "udfs", - "UDFs", StringUtil.VALIDATION_TEXT); - searchUtil.extractString(request, searchCriteria, "databases", - "Databases", StringUtil.VALIDATION_TEXT); - searchUtil.extractString(request, searchCriteria, "groupName", - "Group Name", StringUtil.VALIDATION_TEXT); - searchUtil.extractInt(request, searchCriteria, "resourceType", - "Resource Type"); - searchUtil.extractInt(request, searchCriteria, "assetType", - "Asset Type"); - searchUtil.extractInt(request, searchCriteria, "isEncrypt", - "Is Encrypt"); - searchUtil.extractInt(request, searchCriteria, "isRecursive", - "Is Recursive"); - searchUtil.extractLong(request, searchCriteria, "assetId", "Asset Id"); - searchUtil.extractString(request, searchCriteria, "userName", - "User Name", StringUtil.VALIDATION_TEXT); - - searchUtil.extractLongList(request, searchCriteria, "userId", - "User Id", "userId"); - // searchUtil.extractLong(request, searchCriteria, "userId", - // "User Id"); - // searchUtil.extractLong(request, searchCriteria, "groupId", - // "Group Id"); - searchUtil.extractLongList(request, searchCriteria, "groupId", - "Group Id", "groupId"); - - searchUtil.extractString(request, searchCriteria, "topologies", - "Topology Name", StringUtil.VALIDATION_TEXT); - searchUtil.extractString(request, searchCriteria, "services", - "Service Name", StringUtil.VALIDATION_TEXT); - - // searchUtil.extractIntList(request, searchCriteria, "status", - // "status", "status"); - - // SearchGroup outerGroup = new SearchGroup(SearchGroup.CONDITION.OR); - // // Get the search fields for objectClassType and objectId - // SearchField userId = null; - // SearchField groupId = null; - // SearchField resourceId = null; - // List<SearchField> searchFields = xResourceService.searchFields; - // for (SearchField searchField : searchFields) { - // if (searchField.getClientFieldName().equals("userId") && - // request.getParameterValues("userId")!=null) { - // userId = searchField; - // } else if (searchField.getClientFieldName().equals("groupId") && - // request.getParameterValues("groupId")!=null) { - // groupId = searchField; - // }else if (searchField.getClientFieldName().equals("name") && - // request.getParameterValues("name")!=null) { - // resourceId = searchField; - // } - // } - // if (groupId != null || userId != null || resourceId != null) { - // SearchGroup innerGroup = new SearchGroup(SearchGroup.CONDITION.AND); - // SearchValue searchValue=null; - // if(userId!=null){ - // searchValue = new SearchValue(userId, - // searchCriteria.getParamValue("userId")); - // - // innerGroup.addValue(searchValue); - // } - // if(groupId!=null){ - // searchValue = new SearchValue(groupId, - // searchCriteria.getParamValue("groupId")); - // innerGroup.addValue(searchValue); - // } - // if(resourceId!=null){ - // - // searchValue = new SearchValue(resourceId, - // searchCriteria.getParamValue("name")); - // innerGroup.addValue(searchValue); - // } - // - // outerGroup.addSearchGroup(innerGroup); - // searchUtil.addSearchGroup(searchCriteria, outerGroup); - // - // } - searchCriteria.setDistinct(true); - - return assetMgr.searchXResources(searchCriteria); + if(logger.isDebugEnabled()) { + logger.debug("==> AssetREST.searchXResources()"); + } + + VXResourceList ret = new VXResourceList(); + + String arg = request.getParameter("assetId"); + Long assetId = (arg == null || arg.isEmpty()) ? null : Long.parseLong(arg); + + List<RangerPolicy> policies = assetId != null ? serviceREST.getServicePolicies(assetId, request) : serviceREST.getPolicies(request); + + if(policies != null) { + List<VXResource> resources = new ArrayList<VXResource>(policies.size()); + + for(RangerPolicy policy : policies) { + RangerService service = serviceREST.getServiceByName(policy.getService()); + + resources.add(serviceUtil.toVXResource(policy, service)); + } + + ret.setVXResources(resources); + } + + if(logger.isDebugEnabled()) { + logger.debug("<== AssetREST.searchXResources(): count=" + ret.getResultSize()); + } + + return ret; + } + + @GET + @Path("/resources/count") + @Produces({ "application/xml", "application/json" }) + public VXLong countXResources(@Context HttpServletRequest request) { + if(logger.isDebugEnabled()) { + logger.debug("==> AssetREST.countXResources()"); + } + + VXLong ret = new VXLong(); + + Long count = serviceREST.countPolicies(request); + + ret.setValue(count == null ? 0 : count.longValue()); + + if(logger.isDebugEnabled()) { + logger.debug("<== AssetREST.countXAssets(): " + ret); + } + + return ret; } @GET @@ -385,16 +469,6 @@ public class AssetREST { String topologyName = request.getParameter("topologyName"); return assetMgr.getStormResources(dataSourceName, topologyName); } - - @GET - @Path("/resources/count") - @Produces({ "application/xml", "application/json" }) - public VXLong countXResources(@Context HttpServletRequest request) { - SearchCriteria searchCriteria = searchUtil.extractCommonCriterias( - request, xResourceService.sortFields); - - return assetMgr.getXResourceSearchCount(searchCriteria); - } @GET @Path("/credstores/{id}") http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/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 cc3161a..9080cd9 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 @@ -336,7 +336,7 @@ public class ServiceREST { } @PUT - @Path("/services") + @Path("/services/{id}") @Produces({ "application/json", "application/xml" }) public RangerService updateService(RangerService service) { if(LOG.isDebugEnabled()) { @@ -441,7 +441,8 @@ public class ServiceREST { List<RangerPolicy> ret = null; try { - ret = svcMgr.getAllPolicies(); + Long serviceId = Long.parseLong(request.getParameter("serviceId")); + ret = svcMgr.getPolicies(serviceId); } catch(Exception excp) { throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, excp.getMessage(), true); } http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/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 new file mode 100644 index 0000000..a63e4b2 --- /dev/null +++ b/security-admin/src/main/webapp/scripts/collection_bases/RangerPolicyListBase.js @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +define(function(require){ + 'use strict'; + + var XABaseCollection = require('collections/XABaseCollection'); + var XAGlobals = require('utils/XAGlobals'); + var RangerPolicy = require('models/RangerPolicy'); + + var RangerPolicyListBase = XABaseCollection.extend( + /** @lends RangerPolicyListBase.prototype */ + { + url: XAGlobals.baseURL + 'plugins/policies', + + model : RangerPolicy, + + /** + * RangerPolicyListBase initialize method + * @augments XABaseCollection + * @constructs + */ + initialize : function() { + this.modelName = 'RangerPolicy'; + this.modelAttrName = 'RangerPolicies'; + this.bindErrorEvents(); + }, + /** + * override the parseRecords of PageableCollection for our use + */ + parseRecords : function(resp, options){ + return resp; + } + },{ + // static class members + /** + * Table Cols to be passed to Backgrid + * UI has to use this as base and extend this. + * + */ + + tableCols : {} + + }); + + return RangerPolicyListBase; +}); + + http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/scripts/collection_bases/RangerPolicyResourceListBase.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/collection_bases/RangerPolicyResourceListBase.js b/security-admin/src/main/webapp/scripts/collection_bases/RangerPolicyResourceListBase.js new file mode 100644 index 0000000..6a79729 --- /dev/null +++ b/security-admin/src/main/webapp/scripts/collection_bases/RangerPolicyResourceListBase.js @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +define(function(require){ + 'use strict'; + + var XABaseCollection = require('collections/XABaseCollection'); + var XAGlobals = require('utils/XAGlobals'); + var RangerPolicyResource = require('models/RangerPolicyResource'); + + var RangerPolicyResourceListBase = XABaseCollection.extend( + /** @lends RangerPolicyResourceListBase.prototype */ + { +// url: XAGlobals.baseURL + 'plugins/policies', + + model : RangerPolicyResource, + + /** + * RangerPolicyListBase initialize method + * @augments XABaseCollection + * @constructs + */ + initialize : function() { + this.modelName = 'RangerPolicyResource'; + this.modelAttrName = 'RangerPolicyResources'; + this.bindErrorEvents(); + }, + /** + * override the parseRecords of PageableCollection for our use + */ + parseRecords : function(resp, options){ + return resp; + } + },{ + // static class members + /** + * Table Cols to be passed to Backgrid + * UI has to use this as base and extend this. + * + */ + + tableCols : {} + + }); + + return RangerPolicyResourceListBase; +}); + + http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/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 new file mode 100644 index 0000000..2754f62 --- /dev/null +++ b/security-admin/src/main/webapp/scripts/collection_bases/RangerServiceDefListBase.js @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +define(function(require){ + 'use strict'; + + var XABaseCollection = require('collections/XABaseCollection'); + var XAGlobals = require('utils/XAGlobals'); + var RangerServiceDef = require('models/RangerServiceDef'); + + var RangerServiceDefListBase = XABaseCollection.extend( + /** @lends RangerServiceDefListBase.prototype */ + { + url: XAGlobals.baseURL + 'plugins/definitions', + + model : RangerServiceDef, + + /** + * RangerServiceDefListBase initialize method + * @augments XABaseCollection + * @constructs + */ + initialize : function() { + this.modelName = 'RangerServiceDef'; + this.modelAttrName = 'RangerServiceDefs'; + this.bindErrorEvents(); + }, + /** + * override the parseRecords of PageableCollection for our use + */ + parseRecords : function(resp, options){ + return resp; + }, + comparator: function(def) { + return def.get('id'); + } + + },{ + // static class members + /** + * Table Cols to be passed to Backgrid + * UI has to use this as base and extend this. + * + */ + + tableCols : {} + + }); + + return RangerServiceDefListBase; +}); + + http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/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 new file mode 100644 index 0000000..99d1533 --- /dev/null +++ b/security-admin/src/main/webapp/scripts/collection_bases/RangerServiceListBase.js @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +define(function(require){ + 'use strict'; + + var XABaseCollection = require('collections/XABaseCollection'); + var XAGlobals = require('utils/XAGlobals'); + var RangerService = require('models/RangerService'); + + var RangerServiceListBase = XABaseCollection.extend( + /** @lends RangerServiceListBase.prototype */ + { + url: XAGlobals.baseURL + 'plugins/services', + + model : RangerService, + + /** + * RangerServiceListBase initialize method + * @augments XABaseCollection + * @constructs + */ + initialize : function() { + this.modelName = 'RangerService'; + this.modelAttrName = 'RangerServices'; + this.bindErrorEvents(); + }, + /** + * override the parseRecords of PageableCollection for our use + */ + parseRecords : function(resp, options){ + return resp; + } + },{ + // static class members + /** + * Table Cols to be passed to Backgrid + * UI has to use this as base and extend this. + * + */ + + tableCols : {} + + }); + + return RangerServiceListBase; +}); + + http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/scripts/collections/RangerPolicyList.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/collections/RangerPolicyList.js b/security-admin/src/main/webapp/scripts/collections/RangerPolicyList.js new file mode 100644 index 0000000..a597722 --- /dev/null +++ b/security-admin/src/main/webapp/scripts/collections/RangerPolicyList.js @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +define(function(require){ + 'use strict'; + + var RangerPolicyListBase = require('collection_bases/RangerPolicyListBase'); + + var RangerPolicyList = RangerPolicyListBase.extend( + /** @lends RangerPolicyList.prototype */ + { + },{ + // static class members + }); + + return RangerPolicyList; +}); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/scripts/collections/RangerPolicyResourceList.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/collections/RangerPolicyResourceList.js b/security-admin/src/main/webapp/scripts/collections/RangerPolicyResourceList.js new file mode 100644 index 0000000..a200f7e --- /dev/null +++ b/security-admin/src/main/webapp/scripts/collections/RangerPolicyResourceList.js @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +define(function(require){ + 'use strict'; + + var RangerPolicyResourceListBase = require('collection_bases/RangerPolicyResourceListBase'); + + var RangerPolicyResourceList = RangerPolicyResourceListBase.extend( + /** @lends RangerPolicyResourceList.prototype */ + { + },{ + // static class members + }); + + return RangerPolicyResourceList; +}); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/scripts/collections/RangerServiceDefList.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/collections/RangerServiceDefList.js b/security-admin/src/main/webapp/scripts/collections/RangerServiceDefList.js new file mode 100644 index 0000000..4c04f86 --- /dev/null +++ b/security-admin/src/main/webapp/scripts/collections/RangerServiceDefList.js @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +define(function(require){ + 'use strict'; + + var RangerServiceDefListBase = require('collection_bases/RangerServiceDefListBase'); + + var RangerServiceDefList = RangerServiceDefListBase.extend( + /** @lends RangerServiceDefList.prototype */ + { + },{ + // static class members + }); + + return RangerServiceDefList; +}); + + http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/scripts/collections/RangerServiceList.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/collections/RangerServiceList.js b/security-admin/src/main/webapp/scripts/collections/RangerServiceList.js new file mode 100644 index 0000000..4a1af29 --- /dev/null +++ b/security-admin/src/main/webapp/scripts/collections/RangerServiceList.js @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +define(function(require){ + 'use strict'; + + var RangerServiceListBase = require('collection_bases/RangerServiceListBase'); + + var RangerServiceList = RangerServiceListBase.extend( + /** @lends RangerServiceList.prototype */ + { + },{ + // static class members + }); + + return RangerServiceList; +}); + + http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/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 8b19533..9dc44b5 100644 --- a/security-admin/src/main/webapp/scripts/controllers/Controller.js +++ b/security-admin/src/main/webapp/scripts/controllers/Controller.js @@ -58,8 +58,8 @@ define(function(require) { policyManagerAction :function(){ MAppState.set({ 'currentTab' : XAGlobals.AppTabs.PolicyManager.value }); console.log('Policy Manager action called..'); - var view = require('views/policymanager/PolicyManagerLayout'); - var VXAssetList = require('collections/VXAssetList'); + var view = require('views/policymanager/PolicyManagerLayout'); + var VXAssetList = require('collections/VXAssetList'); var collection = new VXAssetList(); collection.fetch({ @@ -611,6 +611,137 @@ define(function(require) { model : group })); }); - } + }, + + + /************************************************************/ + //************** Generic design Related *********************/ + /************************************************************/ + + serviceManagerAction :function(){ + MAppState.set({ 'currentTab' : XAGlobals.AppTabs.PolicyManager.value }); + console.log('Policy Manager action called..'); + var view = require('views/policymanager/ServiceLayout'); + var RangerServiceDefList = require('collections/RangerServiceDefList'); + var collection = new RangerServiceDefList(); + collection.queryParams.sortBy = 'id'; + collection.fetch({ + cache : false, + async:false + }).done(function(){ + if(App.rContent.currentView) App.rContent.currentView.close(); + //TODO FROM SERVER SIDE IT SHOULD GIVE SORTBY `ID` BY DEFAULT +// collection = collection.sort() + App.rContent.show(new view({ + collection : collection + })); + }); + }, + + serviceCreateAction :function(serviceTypeId){ + MAppState.set({ 'currentTab' : XAGlobals.AppTabs.PolicyManager.value }); + var view = require('views/service/ServiceCreate'); + var RangerServiceDef = require('models/RangerServiceDef'); + var RangerService = require('models/RangerService'); + + var rangerServiceDefModel = new RangerServiceDef({id:serviceTypeId}); + var rangerServiceModel = new RangerService(); +// rangerServiceDefModel.fetch({ +// cache:true +// }).done(function(){ + App.rContent.show(new view({ + model : rangerServiceModel, + serviceTypeId : serviceTypeId + })); +// }); + }, + serviceEditAction :function(serviceTypeId, serviceId){ + MAppState.set({ 'currentTab' : XAGlobals.AppTabs.PolicyManager.value }); + var view = require('views/service/ServiceCreate'); + var RangerServiceDef = require('models/RangerServiceDef'); + var RangerService = require('models/RangerService'); + + var rangerServiceDefModel = new RangerServiceDef({ id : serviceTypeId }); + var rangerService = new RangerService({ 'id' : serviceId }); + + rangerService.fetch({ + cache:false + }).done(function(){ + App.rContent.show(new view({ + model : rangerService, + serviceTypeId :serviceTypeId + })); + }); + }, + + policyManageAction :function(serviceId){ + MAppState.set({ 'currentTab' : XAGlobals.AppTabs.PolicyManager.value }); + var view = require('views/policies/RangerPolicyTableLayout'); + var RangerService = require('models/RangerService'); + var RangerPolicyList = require('collections/RangerPolicyList'); + + var rangerService = new RangerService({id : serviceId}); + var rangerPolicyList = new RangerPolicyList(); + /*var rangerPolicyList = new RangerPolicyList([],{ + queryParams : { + 'serviceId' : serviceId + } + });*/ + rangerPolicyList.url = "service/plugins/services/"+serviceId+"/policies" + + rangerService.fetch({ + cache : false, + async : false + }); + + rangerPolicyList.fetch({ + cache : false, + }).done(function(){ + App.rContent.show(new view({ + collection : rangerPolicyList, + rangerService : rangerService + })); + }); + }, + RangerPolicyCreateAction :function(serviceId){ + MAppState.set({ 'currentTab' : XAGlobals.AppTabs.PolicyManager.value }); + + var view = require('views/policies/RangerPolicyCreate'); + var RangerService = require('models/RangerService'); + var RangerPolicy = require('models/RangerPolicy'); + + var rangerService = new RangerService({id : serviceId}); + rangerService.fetch({ + cache : false, + }).done(function(){ + App.rContent.show(new view({ + model : new RangerPolicy(), + rangerService : rangerService, + })); + }); + }, + RangerPolicyEditAction :function(serviceId, policyId){ + MAppState.set({ 'currentTab' : XAGlobals.AppTabs.PolicyManager.value }); + + var view = require('views/policies/RangerPolicyCreate'); + var RangerService = require('models/RangerService'); + var RangerPolicy = require('models/RangerPolicy'); + + var rangerService = new RangerService({id : serviceId}); + var rangerPolicy = new RangerPolicy({ id : policyId}); + rangerService.fetch({ + cache : false, + async : false, + }); + rangerPolicy.fetch({ + cache : false, + }).done(function(){ + App.rContent.show(new view({ + model : rangerPolicy, + rangerService :rangerService + })); + }); + }, + }); }); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/scripts/model_bases/RangerPolicyBase.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/model_bases/RangerPolicyBase.js b/security-admin/src/main/webapp/scripts/model_bases/RangerPolicyBase.js new file mode 100644 index 0000000..24341e0 --- /dev/null +++ b/security-admin/src/main/webapp/scripts/model_bases/RangerPolicyBase.js @@ -0,0 +1,90 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +define(function(require){ + 'use strict'; + + var XABaseModel = require('models/XABaseModel'); + var XAGlobals = require('utils/XAGlobals'); + + var RangerPolicyBase = XABaseModel.extend( + /** @lends RangerPolicyBase.prototype */ + { + urlRoot: XAGlobals.baseURL + 'plugins/policies', + + defaults: {}, + + serverSchema : { + "id" : { + "dataType" : "Long" + }, + "guid" : { + "dataType" : "String" + }, + "version" : { + "dataType" : "int" + }, + "createTime" : { + "dataType" : "Date" + }, + "updateTime" : { + "dataType" : "Date" + }, + "permList" : { + "dataType" : "list", + "listType" : "VNameValue" + }, + "status" : { + "dataType" : "int" + }, + "name" : { + "dataType" : "String" + }, + "label" : { + "dataType" : "String" + }, + "description" : { + "dataType" : "String" + } + }, + + + idAttribute: 'id', + + /** + * RangerPolicyBase initialize method + * @augments XABaseModel + * @constructs + */ + initialize: function() { + this.modelName = 'RangerPolicyBase'; + //this.bind("error", XAUtils.defaultErrorHandler); + this.bindErrorEvents(); + } + + }, { + // static class members + }); + + return RangerPolicyBase; + +}); + + http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/scripts/model_bases/RangerPolicyResourceBase.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/model_bases/RangerPolicyResourceBase.js b/security-admin/src/main/webapp/scripts/model_bases/RangerPolicyResourceBase.js new file mode 100644 index 0000000..da86aeb --- /dev/null +++ b/security-admin/src/main/webapp/scripts/model_bases/RangerPolicyResourceBase.js @@ -0,0 +1,90 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +define(function(require){ + 'use strict'; + + var XABaseModel = require('models/XABaseModel'); + var XAGlobals = require('utils/XAGlobals'); + + var RangerPolicyResourceBase = XABaseModel.extend( + /** @lends RangerPolicyResourceBase.prototype */ + { +// urlRoot: XAGlobals.baseURL + 'plugins/policies', + + defaults: {}, + + serverSchema : { + "id" : { + "dataType" : "Long" + }, + "guid" : { + "dataType" : "String" + }, + "version" : { + "dataType" : "int" + }, + "createTime" : { + "dataType" : "Date" + }, + "updateTime" : { + "dataType" : "Date" + }, + "permList" : { + "dataType" : "list", + "listType" : "VNameValue" + }, + "status" : { + "dataType" : "int" + }, + "name" : { + "dataType" : "String" + }, + "label" : { + "dataType" : "String" + }, + "description" : { + "dataType" : "String" + } + }, + + + idAttribute: 'id', + + /** + * RangerPolicyResource initialize method + * @augments XABaseModel + * @constructs + */ + initialize: function() { + this.modelName = 'RangerPolicyResource'; + //this.bind("error", XAUtils.defaultErrorHandler); + this.bindErrorEvents(); + } + + }, { + // static class members + }); + + return RangerPolicyResourceBase; + +}); + + http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/scripts/model_bases/RangerServiceBase.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/model_bases/RangerServiceBase.js b/security-admin/src/main/webapp/scripts/model_bases/RangerServiceBase.js new file mode 100644 index 0000000..a4abfda --- /dev/null +++ b/security-admin/src/main/webapp/scripts/model_bases/RangerServiceBase.js @@ -0,0 +1,90 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +define(function(require){ + 'use strict'; + + var XABaseModel = require('models/XABaseModel'); + var XAGlobals = require('utils/XAGlobals'); + + var RangerServiceBase = XABaseModel.extend( + /** @lends RangerServiceBase.prototype */ + { + urlRoot: XAGlobals.baseURL + 'plugins/services', + + defaults: {}, + + serverSchema : { + "id" : { + "dataType" : "Long" + }, + "guid" : { + "dataType" : "String" + }, + "version" : { + "dataType" : "int" + }, + "createTime" : { + "dataType" : "Date" + }, + "updateTime" : { + "dataType" : "Date" + }, + "permList" : { + "dataType" : "list", + "listType" : "VNameValue" + }, + "status" : { + "dataType" : "int" + }, + "name" : { + "dataType" : "String" + }, + "label" : { + "dataType" : "String" + }, + "description" : { + "dataType" : "String" + } + }, + + + idAttribute: 'id', + + /** + * RangerServiceBase initialize method + * @augments XABaseModel + * @constructs + */ + initialize: function() { + this.modelName = 'RangerServiceBase'; + //this.bind("error", XAUtils.defaultErrorHandler); + this.bindErrorEvents(); + } + + }, { + // static class members + }); + + return RangerServiceBase; + +}); + + http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/scripts/model_bases/RangerServiceDefBase.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/model_bases/RangerServiceDefBase.js b/security-admin/src/main/webapp/scripts/model_bases/RangerServiceDefBase.js new file mode 100644 index 0000000..7fb6e12 --- /dev/null +++ b/security-admin/src/main/webapp/scripts/model_bases/RangerServiceDefBase.js @@ -0,0 +1,105 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +define(function(require){ + 'use strict'; + + var XABaseModel = require('models/XABaseModel'); + var XAGlobals = require('utils/XAGlobals'); + + var RangerServiceDefBase = XABaseModel.extend( + /** @lends RangerServiceDefBase.prototype */ + { + urlRoot: XAGlobals.baseURL + 'plugins/definitions', + + defaults: {}, + + serverSchema : { + "id" : { + "dataType" : "Long" + }, + "guid" : { + "dataType" : "String" + }, + "version" : { + "dataType" : "int" + }, + "createTime" : { + "dataType" : "Date" + }, + "updateTime" : { + "dataType" : "Date" + }, + "permList" : { + "dataType" : "list", + "listType" : "VNameValue" + }, + "status" : { + "dataType" : "int" + }, + "name" : { + "dataType" : "String" + }, + "label" : { + "dataType" : "String" + }, + "description" : { + "dataType" : "String" + }, + "configs" : { + "dataType" : "string" + }, + "resources" : { + "dataType" : "string" + }, + "accessTypes" : { + "dataType" : "string" + }, + "policyConditions" : { + "dataType" : "string" + }, + "enums" : { + "dataType" : "string" + } + }, + + + idAttribute: 'id', + + /** + * RangerServiceDefBase initialize method + * @augments XABaseModel + * @constructs + */ + initialize: function() { + this.modelName = 'RangerServiceDefBase'; + //this.bind("error", XAUtils.defaultErrorHandler); + this.bindErrorEvents(); + } + + }, { + // static class members + }); + + return RangerServiceDefBase; + +}); + + http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/scripts/models/RangerPolicy.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/models/RangerPolicy.js b/security-admin/src/main/webapp/scripts/models/RangerPolicy.js new file mode 100644 index 0000000..70de6f7 --- /dev/null +++ b/security-admin/src/main/webapp/scripts/models/RangerPolicy.js @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +define(function(require){ + 'use strict'; + + var RangerPolicyBase = require('model_bases/RangerPolicyBase'); + var XAUtils = require('utils/XAUtils'); + var XAEnums = require('utils/XAEnums'); + var localization= require('utils/XALangSupport'); + + var RangerPolicy = RangerPolicyBase.extend( + /** @lends RangerPolicy.prototype */ + { + /** + * RangerPolicy initialize method + * @augments RangerPolicyBase + * @constructs + */ + initialize: function() { + this.modelName = 'RangerPolicy'; + this.bindErrorEvents(); + }, + /** + * @function schema + * This method is meant to be used by UI, + * by default we will remove the unrequired attributes from serverSchema + */ + + schemaBase : function(){ + var attrs = _.omit(this.serverSchema, 'id', 'createDate', 'updateDate', "version", + "createDate", "updateDate", "permList", "status", "updatedBy", "isSystem"); + + _.each(attrs, function(o){ + o.type = 'Hidden'; + }); + + // Overwrite your schema definition here + return _.extend(attrs,{ + name : { + type : 'Text', + title : 'Policy Name *', + validators : ['required'], + editorAttrs :{ maxlength: 255}, + + }, + description : { + type : 'TextArea', + title : 'Description', + validators : [] + }, + isEnabled : { + type : 'Switch', + title : '',//localization.tt("lbl.policyStatus"), + onText : 'enabled', + offText : 'disabled', + width : '80', + switchOn : true + }, + isRecursive : { + type : 'Switch', + title : localization.tt('lbl.includesAllPathsRecursively'), + onText : 'YES', + offText : 'NO', + switchOn : false, + }, + isAuditEnabled : { + type : 'Switch', + title : localization.tt("lbl.auditLogging"), + onText : 'YES', + offText : 'NO', + switchOn : true + }, + }); + }, + + /** This models toString() */ + toString : function(){ + return this.get('name'); + } + + }, { + // static class members + }); + + return RangerPolicy; + +}); + + http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/scripts/models/RangerPolicyResource.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/models/RangerPolicyResource.js b/security-admin/src/main/webapp/scripts/models/RangerPolicyResource.js new file mode 100644 index 0000000..22444d1 --- /dev/null +++ b/security-admin/src/main/webapp/scripts/models/RangerPolicyResource.js @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +define(function(require){ + 'use strict'; + + var RangerPolicyResourceBase = require('model_bases/RangerPolicyResourceBase'); + var XAUtils = require('utils/XAUtils'); + var XAEnums = require('utils/XAEnums'); + var localization= require('utils/XALangSupport'); + + var RangerPolicyResource = RangerPolicyResourceBase.extend( + /** @lends RangerPolicyResource.prototype */ + { + /** + * RangerPolicy initialize method + * @augments RangerPolicyResource + * @constructs + */ + initialize: function() { + this.modelName = 'RangerPolicyResource'; + this.bindErrorEvents(); + }, + /** + * @function schema + * This method is meant to be used by UI, + * by default we will remove the unrequired attributes from serverSchema + */ + + schemaBase : function(){ + var attrs = _.omit(this.serverSchema, 'id', 'createDate', 'updateDate', "version", + "createDate", "updateDate", "permList", "status", "updatedBy", "isSystem"); + + _.each(attrs, function(o){ + o.type = 'Hidden'; + }); + return; + + }, + + /** This models toString() */ + toString : function(){ + return this.get('name'); + } + + }, { + // static class members + }); + + return RangerPolicyResource; + +}); + + http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/scripts/models/RangerService.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/models/RangerService.js b/security-admin/src/main/webapp/scripts/models/RangerService.js new file mode 100644 index 0000000..9d380db --- /dev/null +++ b/security-admin/src/main/webapp/scripts/models/RangerService.js @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +define(function(require){ + 'use strict'; + + var RangerServiceBase = require('model_bases/RangerServiceBase'); + var XAUtils = require('utils/XAUtils'); + var XAEnums = require('utils/XAEnums'); + var localization= require('utils/XALangSupport'); + + var RangerService = RangerServiceBase.extend( + /** @lends RangerService.prototype */ + { + /** + * RangerService initialize method + * @augments RangerServiceBase + * @constructs + */ + initialize: function() { + this.modelName = 'RangerService'; + this.bindErrorEvents(); + }, + /** + * @function schema + * This method is meant to be used by UI, + * by default we will remove the unrequired attributes from serverSchema + */ + + schemaBase : function(){ + var attrs = _.omit(this.serverSchema, 'id', 'createDate', 'updateDate', "version", + "createDate", "updateDate", "permList", "status", "updatedBy", "isSystem"); + + _.each(attrs, function(o){ + o.type = 'Hidden'; + }); + + // Overwrite your schema definition here + return _.extend(attrs,{}); + }, + + /** This models toString() */ + toString : function(){ + return this.get('name'); + } + + }, { + // static class members + }); + + return RangerService; + +}); + + http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/scripts/models/RangerServiceDef.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/models/RangerServiceDef.js b/security-admin/src/main/webapp/scripts/models/RangerServiceDef.js new file mode 100644 index 0000000..e628ee5 --- /dev/null +++ b/security-admin/src/main/webapp/scripts/models/RangerServiceDef.js @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +define(function(require){ + 'use strict'; + + var RangerServiceDefBase = require('model_bases/RangerServiceDefBase'); + var XAUtils = require('utils/XAUtils'); + var XAEnums = require('utils/XAEnums'); + var localization= require('utils/XALangSupport'); + + var RangerServiceDef = RangerServiceDefBase.extend( + /** @lends RangerServiceDef.prototype */ + { + /** + * RangerServiceDef initialize method + * @augments RangerServiceDefBase + * @constructs + */ + initialize: function() { + this.modelName = 'RangerServiceDef'; + this.bindErrorEvents(); + }, + /** + * @function schema + * This method is meant to be used by UI, + * by default we will remove the unrequired attributes from serverSchema + */ + + schemaBase : function(){ + var attrs = _.omit(this.serverSchema, 'id', 'createDate', 'updateDate', "version", + "createDate", "updateDate", "displayOption", + "permList", "status", "updatedBy"); + + _.each(attrs, function(o){ + o.type = 'Hidden'; + }); + + // Overwrite your schema definition here + return _.extend(attrs,{ + name : { + type : 'Text', + title : 'Repository Name *', + validators : ['required'], + editorAttrs :{ maxlength: 255}, + + }, + description : { + type : 'TextArea', + title : 'Description', + validators : [] + }, + isEnabled : { + type : 'Radio', + title : 'Active Status', + options : function(callback, editor){ + var activeStatus = _.filter(XAEnums.ActiveStatus,function(m){return m.label != 'Deleted'}); + var nvPairs = XAUtils.enumToSelectPairs(activeStatus); + callback(_.sortBy(nvPairs, function(n){ return !n.val; })); + } + } + }); + }, + + /** This models toString() */ + toString : function(){ + return this.get('name'); + } + + }, { + // static class members + }); + + return RangerServiceDef; + +}); + + http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/scripts/modules/XALinks.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/modules/XALinks.js b/security-admin/src/main/webapp/scripts/modules/XALinks.js index 9ea26be..52e6c01 100644 --- a/security-admin/src/main/webapp/scripts/modules/XALinks.js +++ b/security-admin/src/main/webapp/scripts/modules/XALinks.js @@ -182,10 +182,36 @@ define(function(require) { title: 'lbl.editAsset' }; }, + + ServiceCreate : function(options){ + var href = '#!/service/create'; + if(_.has(options,'model')){ + href = '#!/service/create/'+options.model.get('assetType'); + } + return { + href : href, + text : 'lbl.createAsset', + title: 'lbl.createAsset' + }; + }, + ServiceEdit : function(options){ + var href = "javascript:void(0);"; + if(_.has(options,'model')){ + href = '#!/service/'+options.model.get('id'); + } + if(_.has(options,'id')){ + href = '#!/service/'+options.id; + } + return { + href : href, + text : 'lbl.editAsset', + title: 'lbl.editAsset' + }; + }, ManagePolicies : function(options){ var href = "javascript:void(0);"; if(_.has(options,'model')){ - href = '#!/hdfs/'+options.model.id+"/policies"; + href = '#!/service/'+options.model.id+"/policies"; } return { href : href, http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/scripts/modules/XAOverrides.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/modules/XAOverrides.js b/security-admin/src/main/webapp/scripts/modules/XAOverrides.js index e842647..72bcaab 100644 --- a/security-admin/src/main/webapp/scripts/modules/XAOverrides.js +++ b/security-admin/src/main/webapp/scripts/modules/XAOverrides.js @@ -310,7 +310,7 @@ }, getValue: function() { - return this.$el.find('.toggle-slide').hasClass('active')? XAEnums.BooleanValue.BOOL_TRUE.value : XAEnums.BooleanValue.BOOL_FALSE.value ; + return this.$el.find('.toggle-slide').hasClass('active')? true: false; //return this.$el.find('.active').text() == "ON" ? true : false; }, http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/scripts/routers/Router.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/routers/Router.js b/security-admin/src/main/webapp/scripts/routers/Router.js index bd1aa36..3cafdae 100644 --- a/security-admin/src/main/webapp/scripts/routers/Router.js +++ b/security-admin/src/main/webapp/scripts/routers/Router.js @@ -27,8 +27,8 @@ function(Backbone){ return Backbone.Marionette.AppRouter.extend({ /** Backbone routes hash */ appRoutes: { - "" : "policyManagerAction",//"dashboardAction", - "!/policymanager" : "policyManagerAction", + "" : "serviceManagerAction",//"dashboardAction", + "!/policymanager" : "serviceManagerAction", /* HDFS related */ "!/hdfs" : "hdfsManageAction", @@ -79,7 +79,17 @@ function(Backbone){ "!/user/:id" : "userEditAction", "!/group/create" : "groupCreateAction", - "!/group/:id" : "groupEditAction" + "!/group/:id" : "groupEditAction", + + /************GENERIC UI *****************************************/ + /****** Service related **********************/ + "!/service/:serviceType/create" : "serviceCreateAction", + "!/service/:serviceType/edit/:id" : "serviceEditAction", + + "!/service/:serviceId/policies" : "policyManageAction", + "!/service/:serviceId/policies/create" : "RangerPolicyCreateAction", + "!/service/:serviceId/policies/:id/edit": "RangerPolicyEditAction" + } }); }); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/scripts/utils/XAEnums.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/utils/XAEnums.js b/security-admin/src/main/webapp/scripts/utils/XAEnums.js index 694bf11..1a28c11 100644 --- a/security-admin/src/main/webapp/scripts/utils/XAEnums.js +++ b/security-admin/src/main/webapp/scripts/utils/XAEnums.js @@ -88,6 +88,15 @@ define(function(require) { ASSET_KNOX:{value:5, label:'Knox', rbkey:'xa.enum.AssetType.ASSET_KNOX', tt: 'lbl.AssetType_ASSET_KNOX'}, ASSET_STORM:{value:6, label:'Storm', rbkey:'xa.enum.AssetType.ASSET_STORM', tt: 'lbl.AssetType_ASSET_STORM'} }); + + XAEnums.ServiceType = mergeParams(XAEnums.ServiceType, { + Service_UNKNOWN:{value:0, label:'Unknown', rbkey:'xa.enum.AssetType.ASSET_UNKNOWN', tt: 'lbl.AssetType_ASSET_UNKNOWN'}, + Service_HDFS:{value:1, label:'hdfs', rbkey:'xa.enum.AssetType.ASSET_HDFS', tt: 'lbl.AssetType_ASSET_HDFS'}, + Service_HIVE:{value:2, label:'hive', rbkey:'xa.enum.AssetType.ASSET_HIVE', tt: 'lbl.AssetType_ASSET_HIVE'}, + Service_HBASE:{value:3, label:'hbase', rbkey:'xa.enum.AssetType.ASSET_HBASE', tt: 'lbl.AssetType_ASSET_HBASE'}, + Service_KNOX:{value:4, label:'knox', rbkey:'xa.enum.AssetType.ASSET_KNOX', tt: 'lbl.AssetType_ASSET_KNOX'}, + Service_STORM:{value:5, label:'storm', rbkey:'xa.enum.AssetType.ASSET_STORM', tt: 'lbl.AssetType_ASSET_STORM'} + }); XAEnums.AuthStatus = mergeParams(XAEnums.AuthStatus, { AUTH_STATUS_UNKNOWN:{value:0, label:'Unknown', rbkey:'xa.enum.AuthStatus.AUTH_STATUS_UNKNOWN', tt: 'lbl.AuthStatus_AUTH_STATUS_UNKNOWN'}, @@ -324,4 +333,4 @@ define(function(require) { }); return XAEnums; -}); +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9d85cb76/security-admin/src/main/webapp/scripts/utils/XAUtils.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/utils/XAUtils.js b/security-admin/src/main/webapp/scripts/utils/XAUtils.js index 68b25a7..41ebe43 100644 --- a/security-admin/src/main/webapp/scripts/utils/XAUtils.js +++ b/security-admin/src/main/webapp/scripts/utils/XAUtils.js @@ -374,37 +374,22 @@ define(function(require) { // [1] => [ {id: 18, groupId : 1, permType :5}, {id: 18, groupId : 1, permType :4} ] // [2] => [ {id: 18, groupId : 2, permType :5} ] if(!model.isNew()){ - if(!_.isUndefined(model.get('permMapList'))){ - var vPermMapList = model.get('permMapList'); //model.get('_vPermMapList'); - var groupPerms = _.filter(vPermMapList,function(m){if(m.permFor == XAEnums.XAPermForType.XA_PERM_FOR_GROUP.value ) return m;}); - var permsGroupBy = _.groupBy(groupPerms,function(m) { return m.permGroup; }); - _.each(permsGroupBy,function(values, g){ - if(g != 'undefined'){ - var idPermMapArr = []; // This should be array of integers of perms eg. [1,2,5] - var groupIds=[],groupNames=[]; - _.each(values, function(v){ - if(groupIds.indexOf(v.groupId) == -1) - groupIds.push(v.groupId); - if(groupNames.indexOf(v.groupName ) == -1) - groupNames.push(v.groupName); - if(_.isEmpty(_.findWhere(idPermMapArr, {permType: v.permType}))) - idPermMapArr.push( { id : v.id,permType :v.permType, groupId :v.groupId} ); - }); - + if(!_.isUndefined(model.get('policyItems'))){ + var policyItems = model.get('policyItems'); + var groupPolicyItems = _.filter(policyItems,function(m){if(!_.isEmpty(m.groups)) return m;}); + _.each(groupPolicyItems,function(obj){ var m = new Backbone.Model({ - groupId : groupIds.join(','), - groupName : groupNames.join(','), - ipAddress : values[0].ipAddress, +// groupId : groupIds.join(','), + groupName : obj.groups.join(','), +// ipAddress : values[0].ipAddress, editMode : true, - + accesses : obj.accesses }); - m.set('_vPermList', idPermMapArr); formInputColl.add(m); - } }); } - } + } return formInputColl; }; @@ -415,38 +400,22 @@ define(function(require) { // [1] => [ {id: 18, groupId : 1, permType :5}, {id: 18, groupId : 1, permType :4} ] // [2] => [ {id: 18, groupId : 2, permType :5} ] if(!model.isNew()){ - if(!_.isUndefined(model.get('permMapList'))){ - var vPermMapList = model.get('permMapList');//model.get('_vPermMapList'); - var userPerms = _.filter(vPermMapList, function(m){if(m.permFor == XAEnums.XAPermForType.XA_PERM_FOR_USER.value) return m;}); - var userPermsGroupBy = _.groupBy(userPerms,function(m) { return m.permGroup; }); - _.each(userPermsGroupBy,function(values, g){ - if(g != 'undefined'){ - var idPermMapArr = []; // This should be array of integers of perms eg. [1,2,5] - - var userIds=[],userNames=[]; - _.each(values, function(v){ - if(userIds.indexOf(v.userId) == -1) - userIds.push(v.userId); - if(userNames.indexOf(v.userName) == -1) - userNames.push(v.userName); - if(_.isEmpty(_.findWhere(idPermMapArr, {permType: v.permType}))) - idPermMapArr.push( { id : v.id,permType :v.permType, userId :v.userId } ); - }); - + if(!_.isUndefined(model.get('policyItems'))){ + var policyItems = model.get('policyItems'); + var userPolicyItems = _.filter(policyItems,function(m){if(!_.isEmpty(m.users)) return m;}); + _.each(userPolicyItems,function(obj){ var m = new Backbone.Model({ - userId : userIds.join(','), - userName : userNames.join(','), - ipAddress : values[0].ipAddress, - editMode : true +// userId : groupIds.join(','), + userName : obj.users.join(','), +// ipAddress : values[0].ipAddress, + editMode : true, + accesses : obj.accesses }); - - m.set('_vPermList', idPermMapArr); coll.add(m); - } - }); + }); } - } + } return coll; }; XAUtils.checkDirtyField = function(arg1, arg2, $elem) {
