Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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("\"");
}

Expand Down Expand Up @@ -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);
Expand All @@ -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("}");
Expand All @@ -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);
Expand All @@ -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);
}

Expand All @@ -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);
Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 = () -> {
Expand All @@ -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)) {
Expand Down Expand Up @@ -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;
};
}

Expand Down