mneethiraj commented on code in PR #1372:
URL: https://github.com/apache/ranger/pull/1372#discussion_r4608712055
##########
agents-common/src/main/java/org/apache/ranger/plugin/service/RangerBaseService.java:
##########
@@ -368,6 +378,41 @@ private void
addCustomRangerDefaultPolicies(List<RangerPolicy> ret, Map<String,
ret.add(policy);
}
+ private void addDefaultPolicyFromJson(List<RangerPolicy> ret, String
configName, String policyJson) {
+ RangerPolicy policy = null;
+
+ if (StringUtils.isNotBlank(policyJson)) {
+ try {
+ policy = JsonUtilsV2.jsonToObj(policyJson, RangerPolicy.class);
+ } catch (IOException e) {
+ LOG.error("{}: failed to parse '{}' in service-config as a
policy. Ignored", getServiceName(), configName, e);
+ }
+ }
+
+ if (policy == null) {
+ LOG.warn("{}: no policy specified in '{}'. Ignored",
getServiceName(), configName);
+ } else if (MapUtils.isEmpty(policy.getResources())) {
+ LOG.warn("{}: no resources specified for default policy '{}' in
'{}'. Ignored", getServiceName(), policy.getName(), configName);
+ } else {
+ if (StringUtils.isBlank(policy.getName())) {
+ policy.setName(DEFAULT_FULL_POLICY_NAME_PREFIX +
configName.substring(PROP_DEFAULT_FULL_POLICY.length()));
Review Comment:
`policy.setName(configName);`
##########
agents-common/src/main/java/org/apache/ranger/plugin/service/RangerBaseService.java:
##########
@@ -368,6 +378,41 @@ private void
addCustomRangerDefaultPolicies(List<RangerPolicy> ret, Map<String,
ret.add(policy);
}
+ private void addDefaultPolicyFromJson(List<RangerPolicy> ret, String
configName, String policyJson) {
+ RangerPolicy policy = null;
+
+ if (StringUtils.isNotBlank(policyJson)) {
+ try {
+ policy = JsonUtilsV2.jsonToObj(policyJson, RangerPolicy.class);
+ } catch (IOException e) {
+ LOG.error("{}: failed to parse '{}' in service-config as a
policy. Ignored", getServiceName(), configName, e);
+ }
+ }
+
+ if (policy == null) {
+ LOG.warn("{}: no policy specified in '{}'. Ignored",
getServiceName(), configName);
+ } else if (MapUtils.isEmpty(policy.getResources())) {
+ LOG.warn("{}: no resources specified for default policy '{}' in
'{}'. Ignored", getServiceName(), policy.getName(), configName);
+ } else {
+ if (StringUtils.isBlank(policy.getName())) {
+ policy.setName(DEFAULT_FULL_POLICY_NAME_PREFIX +
configName.substring(PROP_DEFAULT_FULL_POLICY.length()));
+ }
+
+ policy.setId(null);
+ policy.setGuid(null);
+ policy.setVersion(1L);
+ policy.setService(serviceName);
+
+ if (StringUtils.isEmpty(policy.getDescription())) {
+ policy.setDescription("Policy for " + policy.getName());
Review Comment:
`policy.setDescription(configName);`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]