ItemIterator items = collection.getItems();  int mycount = 0;  while( items.hasNext() ) { mycount++;   TableRowIterator tri = DatabaseManager.query(c, "resourcepolicy", "SELECT * FROM resourcepolicy WHERE " + "resource_type_id=" + Constants.COLLECTION + " AND " + "resource_id="      + collection_id        + " AND " + "action_id="        + Constants.READ       + ";" );  Item i = items.next(); System.out.println(mycount + ": Replacing policy for item " + i.getID() );  i.replaceAllPolicies(tri); }
syncCollection(c, collection);
    public static void main(String argv[])        throws Exception    {        Context c = new Context();        // turn off authorization        c.setIgnoreAuthorization(true);        int collection_id = Integer.parseInt(argv[0]);        System.out.println("Collection ID: " + collection_id);        Collection collection = Collection.find(c, collection_id);        // find all items in a collection, and clone the collection's read policy        ItemIterator items = collection.getItems();        int mycount = 0;        while( items.hasNext() )        {            mycount++;            // now get the collection's read policies            TableRowIterator tri = DatabaseManager.query(c,                "resourcepolicy",                "SELECT * FROM resourcepolicy WHERE " +                "resource_type_id=" + Constants.COLLECTION + " AND " +                "resource_id="      + collection_id        + " AND " +                "action_id="        + Constants.READ       + ";" );            Item i = items.next();	        System.out.println(mycount + ": Replacing policy for item " + i.getID() );            i.replaceAllPolicies(tri);        }    	c.complete();    }