private List<Statement> newObjectStatement(PolicyType policy,String prefix){
  List<Statement> statements=new ArrayList<Statement>();
  if (policy == PolicyType.NONE || bucketName == null || bucketName.isEmpty()) {
    return statements;
  }
  Resources resources=new Resources(Constants.AWS_RESOURCE_PREFIX + bucketName + "/"+ prefix+ "*");
  Statement statement=new Statement();
  statement.setEffect("Allow");
  statement.setPrincipal(new Principal("*"));
  statement.setResources(resources);
  statement.setSid("");
  if (policy == PolicyType.READ_ONLY) {
    statement.setActions(Constants.READ_ONLY_OBJECT_ACTIONS);
  }
 else   if (policy == PolicyType.WRITE_ONLY) {
    statement.setActions(Constants.WRITE_ONLY_OBJECT_ACTIONS);
  }
 else   if (policy == PolicyType.READ_WRITE) {
    statement.setActions(Constants.READ_WRITE_OBJECT_ACTIONS);
  }
  statements.add(statement);
  return statements;
}

private List < Statement > newObjectStatement ( PolicyType policy , String prefix ) { List < Statement > statements = new ArrayList < Statement > ( ) ; if ( policy == PolicyType . NONE || bucketName == null || bucketName . isEmpty ( ) ) { return statements ; } Resources resources = new Resources ( Constants . AWS_RESOURCE_PREFIX + bucketName + "/" + prefix + "*" ) ; Statement statement = new Statement ( ) ; statement . setEffect ( "Allow" ) ; statement . setPrincipal ( new Principal ( "*" ) ) ; statement . setResources ( resources ) ; statement . setSid ( "" ) ; if ( policy == PolicyType . READ_ONLY ) { statement . setActions ( Constants . READ_ONLY_OBJECT_ACTIONS ) ; } else if ( policy == PolicyType . WRITE_ONLY ) { statement . setActions ( Constants . WRITE_ONLY_OBJECT_ACTIONS ) ; } else if ( policy == PolicyType . READ_WRITE ) { statement . setActions ( Constants . READ_WRITE_OBJECT_ACTIONS ) ; } statements . add ( statement ) ; return statements ; }
returns new object statements for given policy type .
