This is an automated email from the ASF dual-hosted git repository.

madhan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ranger.git


The following commit(s) were added to refs/heads/master by this push:
     new a6f7b58d0 RANGER-5049: checkstyle compliance updates - plugin-solr 
module - #2 (#539)
a6f7b58d0 is described below

commit a6f7b58d0d1776a3cdb5d3c7c9961e0103719e6a
Author: Madhan Neethiraj <[email protected]>
AuthorDate: Thu Mar 6 15:42:55 2025 -0800

    RANGER-5049: checkstyle compliance updates - plugin-solr module - #2 (#539)
---
 .../solr/authorizer/RangerSolrAuthorizer.java      |  16 +--
 .../services/solr/client/ServiceSolrClient.java    | 142 ++++++++++-----------
 2 files changed, 77 insertions(+), 81 deletions(-)

diff --git 
a/plugin-solr/src/main/java/org/apache/ranger/authorization/solr/authorizer/RangerSolrAuthorizer.java
 
b/plugin-solr/src/main/java/org/apache/ranger/authorization/solr/authorizer/RangerSolrAuthorizer.java
index 7f1809a94..58c26f38a 100644
--- 
a/plugin-solr/src/main/java/org/apache/ranger/authorization/solr/authorizer/RangerSolrAuthorizer.java
+++ 
b/plugin-solr/src/main/java/org/apache/ranger/authorization/solr/authorizer/RangerSolrAuthorizer.java
@@ -327,7 +327,7 @@ public void init(Map<String, Object> initInfo) {
                         logger.info("Calling solrPlugin.init()");
 
                         me.init();
-                        me.setResultProcessor(new 
RangerSolrAuditHandler(solrPlugin.getConfig()));
+                        me.setResultProcessor(new 
RangerSolrAuditHandler(me.getConfig()));
 
                         solrPlugin = me;
                     }
@@ -736,7 +736,7 @@ private String getConjunctiveFilterQueryStr(Set<String> 
roles) {
                 .append(" 
set_value=\"").append(Joiner.on(',').join(roles.iterator())).append("\"")
                 .append(" 
count_field=\"").append(tokenCountField).append("\"");
 
-        if (allRolesToken != null && !allRolesToken.equals("")) {
+        if (allRolesToken != null && !allRolesToken.isEmpty()) {
             filterQuery.append(" 
wildcard_token=\"").append(allRolesToken).append("\"");
         }
 
@@ -878,7 +878,7 @@ private String buildSimpleORFilterQuery(String fieldName, 
Collection<String> att
         }
 
         if (extraOpts != null && !extraOpts.isEmpty()) {
-            s.append(extraOpts + " ");
+            s.append(extraOpts).append(" ");
         }
 
         s.deleteCharAt(s.length() - 1);
@@ -904,7 +904,7 @@ private String buildSubsetFilterQuery(String fieldName, 
Collection<String> attri
         }
 
         if (extraOpts != null && !extraOpts.isEmpty()) {
-            s.append(" " + extraOpts);
+            s.append(" ").append(extraOpts);
         }
 
         s.append("}");
@@ -917,7 +917,7 @@ private String buildGreaterThanFilterQuery(String 
fieldName, Collection<String>
 
         if (attributeValues.size() == 1) {
             value = attributeValues.iterator().next();
-        } else if (allUsersValue != null && !allUsersValue.equals("")) {
+        } else if (allUsersValue != null && !allUsersValue.isEmpty()) {
             value = allUsersValue;
         } else {
             throw new IllegalArgumentException("Greater Than Filter Query 
cannot be built for field " + fieldName);
@@ -929,7 +929,7 @@ private String buildGreaterThanFilterQuery(String 
fieldName, Collection<String>
             extraClause.append(" (*:* AND -").append(fieldName).append(":*)");
         }
 
-        if (extraOpts != null && !extraOpts.equals("")) {
+        if (extraOpts != null && !extraOpts.isEmpty()) {
             extraClause.append(" ").append(extraOpts);
         }
 
@@ -941,7 +941,7 @@ private String buildLessThanFilterQuery(String fieldName, 
Collection<String> att
 
         if (attributeValues.size() == 1) {
             value = attributeValues.iterator().next();
-        } else if (allUsersValue != null && !allUsersValue.equals("")) {
+        } else if (allUsersValue != null && !allUsersValue.isEmpty()) {
             value = allUsersValue;
         } else {
             throw new IllegalArgumentException("Less Than Filter Query cannot 
be built for field " + fieldName);
@@ -953,7 +953,7 @@ private String buildLessThanFilterQuery(String fieldName, 
Collection<String> att
             extraClause.append(" (*:* AND -").append(fieldName).append(":*)");
         }
 
-        if (extraOpts != null && !extraOpts.equals("")) {
+        if (extraOpts != null && !extraOpts.isEmpty()) {
             extraClause.append(" ").append(extraOpts);
         }
 
diff --git 
a/plugin-solr/src/main/java/org/apache/ranger/services/solr/client/ServiceSolrClient.java
 
b/plugin-solr/src/main/java/org/apache/ranger/services/solr/client/ServiceSolrClient.java
index 76cd12c5a..44033b97e 100644
--- 
a/plugin-solr/src/main/java/org/apache/ranger/services/solr/client/ServiceSolrClient.java
+++ 
b/plugin-solr/src/main/java/org/apache/ranger/services/solr/client/ServiceSolrClient.java
@@ -66,14 +66,14 @@
 public class ServiceSolrClient {
     private static final Logger LOG = 
LoggerFactory.getLogger(ServiceSolrClient.class);
 
-    private final String     url;
-    private final String     username;
-    private final String     password;
-    private final String     serviceName;
-    private final String     authType;
-    private final boolean    isKerberosAuth;
-
-    private boolean    isSolrCloud;
+    private final String  url;
+    private final String  username;
+    private final String  password;
+    private final String  serviceName;
+    private final String  authType;
+    private final boolean isKerberosAuth;
+    private final boolean isSolrCloud;
+
     private Subject    loginSubject;
     private SolrClient solrClient;
 
@@ -161,44 +161,41 @@ public List<String> getResources(ResourceLookupContext 
context) {
 
                 if (lookupResource == 
RangerSolrConstants.ResourceType.COLLECTION) {
                     // get the collection list for given Input
-                    callableObj = new Callable<List<String>>() {
-                        @Override
-                        public List<String> call() {
-                            List<String> retList = new ArrayList<>();
-
-                            try {
-                                List<String> list = null;
-
-                                if (isKerberosAuth) {
-                                    list = Subject.doAs(loginSubject, 
(PrivilegedAction<List<String>>) () -> {
-                                        List<String> ret = null;
-
-                                        try {
-                                            ret = 
getCollectionList(finalCollectionList);
-                                        } catch (Exception e) {
-                                            LOG.error("Unable to get 
collections, Error : {}", e.getMessage(), new Throwable(e));
-                                        }
-                                        return ret;
-                                    });
-                                } else {
-                                    list = 
getCollectionList(finalCollectionList);
-                                }
+                    callableObj = () -> {
+                        List<String> retList = new ArrayList<>();
 
-                                if (userInputFinal != null && 
!userInputFinal.isEmpty()) {
-                                    for (String value : list) {
-                                        if (value.startsWith(userInputFinal)) {
-                                            retList.add(value);
-                                        }
+                        try {
+                            List<String> list;
+
+                            if (isKerberosAuth) {
+                                list = Subject.doAs(loginSubject, 
(PrivilegedAction<List<String>>) () -> {
+                                    List<String> ret = null;
+
+                                    try {
+                                        ret = 
getCollectionList(finalCollectionList);
+                                    } catch (Exception e) {
+                                        LOG.error("Unable to get collections, 
Error : {}", e.getMessage(), new Throwable(e));
                                     }
-                                } else {
-                                    retList.addAll(list);
-                                }
-                            } catch (Exception ex) {
-                                LOG.error("Error getting collections.", ex);
+                                    return ret;
+                                });
+                            } else {
+                                list = getCollectionList(finalCollectionList);
                             }
 
-                            return retList;
+                            if (userInputFinal != null && 
!userInputFinal.isEmpty()) {
+                                for (String value : list) {
+                                    if (value.startsWith(userInputFinal)) {
+                                        retList.add(value);
+                                    }
+                                }
+                            } else {
+                                retList.addAll(list);
+                            }
+                        } catch (Exception ex) {
+                            LOG.error("Error getting collections.", ex);
                         }
+
+                        return retList;
                     };
                 } else if (lookupResource == 
RangerSolrConstants.ResourceType.FIELD) {
                     callableObj = () -> {
@@ -221,6 +218,7 @@ public List<String> call() {
                             } else {
                                 list = getFieldList(finalCollectionList, 
finalFieldList);
                             }
+
                             if (userInputFinal != null && 
!userInputFinal.isEmpty()) {
                                 for (String value : list) {
                                     if (value.startsWith(userInputFinal)) {
@@ -295,42 +293,40 @@ public List<String> call() {
                     resultList = retList;
                 } else if (lookupResource == 
RangerSolrConstants.ResourceType.SCHEMA) {
                     // get the collection list for given Input, since there is 
no way of getting a list of the available schemas
-                    callableObj = new Callable<List<String>>() {
-                        @Override
-                        public List<String> call() {
-                            List<String> retList = new ArrayList<>();
-
-                            try {
-                                List<String> list;
-
-                                if (isKerberosAuth) {
-                                    list = Subject.doAs(loginSubject, 
(PrivilegedAction<List<String>>) () -> {
-                                        List<String> ret = null;
-
-                                        try {
-                                            ret = 
getSchemaList(finalSchemaList);
-                                        } catch (Exception e) {
-                                            LOG.error("Unable to get 
collections for schema listing, Error : {}", e.getMessage(), new Throwable(e));
-                                        }
-                                        return ret;
-                                    });
-                                } else {
-                                    list = getSchemaList(finalSchemaList);
-                                }
-                                if (userInputFinal != null && 
!userInputFinal.isEmpty()) {
-                                    for (String value : list) {
-                                        if (value.startsWith(userInputFinal)) {
-                                            retList.add(value);
-                                        }
+                    callableObj = () -> {
+                        List<String> retList = new ArrayList<>();
+
+                        try {
+                            List<String> list;
+
+                            if (isKerberosAuth) {
+                                list = Subject.doAs(loginSubject, 
(PrivilegedAction<List<String>>) () -> {
+                                    List<String> ret = null;
+
+                                    try {
+                                        ret = getSchemaList(finalSchemaList);
+                                    } catch (Exception e) {
+                                        LOG.error("Unable to get collections 
for schema listing, Error : {}", e.getMessage(), new Throwable(e));
+                                    }
+                                    return ret;
+                                });
+                            } else {
+                                list = getSchemaList(finalSchemaList);
+                            }
+                            if (userInputFinal != null && 
!userInputFinal.isEmpty()) {
+                                for (String value : list) {
+                                    if (value.startsWith(userInputFinal)) {
+                                        retList.add(value);
                                     }
-                                } else {
-                                    retList.addAll(list);
                                 }
-                            } catch (Exception ex) {
-                                LOG.error("Error getting collections for 
schema listing.", ex);
+                            } else {
+                                retList.addAll(list);
                             }
-                            return retList;
+                        } catch (Exception ex) {
+                            LOG.error("Error getting collections for schema 
listing.", ex);
                         }
+
+                        return retList;
                     };
                 }
 

Reply via email to