private List<Rule> parseRules(JSONArray rules) throws AdeUsageException, JSONException {
  if (rules.length() == 0)   throw new AdeUsageException("No rules specified");
  List<Rule> currentRules=new ArrayList<Rule>();
  for (int i=0; i < rules.length(); i++) {
    JSONObject rule=rules.getJSONObject(i);
    String name=rule.getString("name");
    String description=rule.getString("description");
    String membershipRule=rule.getString("membershipRule");
    if (!verifyStringParam(name,200,"[a-zA-Z0-9_ ]*") || (description != null && description.length() > 1000) || name.equalsIgnoreCase("unassigned_rule")|| !verifyStringParam(membershipRule,256,"[a-zA-Z0-9.:?/*-]*")) {
      throw new AdeUsageException("Invalid parameters for rules was specified");
    }
    currentRules.add(new Rule(name,membershipRule,description));
    validateRuleNames(currentRules);
  }
  return currentRules;
}

private List < Rule > parseRules ( JSONArray rules ) throws AdeUsageException , JSONException { if ( rules . length ( ) == 0 ) throw new AdeUsageException ( "No rules specified" ) ; List < Rule > currentRules = new ArrayList < Rule > ( ) ; for ( int i = 0 ; i < rules . length ( ) ; i ++ ) { JSONObject rule = rules . getJSONObject ( i ) ; String name = rule . getString ( "name" ) ; String description = rule . getString ( "description" ) ; String membershipRule = rule . getString ( "membershipRule" ) ; if ( ! verifyStringParam ( name , 200 , "[a-zA-Z0-9_ ]*" ) || ( description != null && description . length ( ) > 1000 ) || name . equalsIgnoreCase ( "unassigned_rule" ) || ! verifyStringParam ( membershipRule , 256 , "[a-zA-Z0-9.:?/*-]*" ) ) { throw new AdeUsageException ( "Invalid parameters for rules was specified" ) ; } currentRules . add ( new Rule ( name , membershipRule , description ) ) ; validateRuleNames ( currentRules ) ; } return currentRules ; }
main logic for parsing the rules from the json file . also does validation of the rules attributes .
