I am searching products with flexible query which is working fine on hac. While writing flexible query in my java class I want to disable all restriction and for that I am using following code
public class abc
{
@Resource
private UserService userService;
private SearchRestrictionService searchRestrictionService;
public List<ProductModel> findProducts()
{
final String query = "select {p:name},{p.creationtime},from {Product! as p} ";
userService.setCurrentUser(userService.getAdminUser());
try
{
this.searchRestrictionService.disableSearchRestrictions();
}
catch (final NullPointerException e)
{
System.out.println("Problem in restriction");
e.printStackTrace();
}
} }
Above is a part of my code. On executing above code I am getting message in output as "Problem in restriction" as I have set this message for null pointer exception. Please suggest ho can i remove this exception from restriction property.