The solution that i give to you is not linked with a query or page size, you can follow this steps (I faced the same problem once and this one worked for me )
Create a saver class
A saver class is a Java class that hold the most important informations about your repository ( when i speak about repository i mean Folder + File)
The informations that you have to use in your saver class
1 - Name
2 - Path ( You will build it)
3 - Alfresco ID
Use a recursive function
This function parcour all the tree and save every element in you saver class, it will look like this
public void getTree(Tree<FileableCmisObject> tree, SaverClass father, String serverURL, String login, String password) {
SaverClass enr = new SaverClass ();
enr.setName(tree.getItem().getName());
if ((father.getPath()).equals("/")) /// IN CASE IT'S THE ROOT
{
enr.setPath("/" + tree.getItem().getName());
} else {
enr.setPath(father.getPath() + "/" + tree.getItem().getName());
}
enr.setFather(father.getNom());
for (Tree<FileableCmisObject> t : tree.getChildren()) {
getTree(t, enr, serverURL, login, password);
}
}
Once you save all the elements in a list you only have to use the migration method for every element of the list (if you want to use the Alfresco ID it's OK , if you want to use the Path it's OK)
Hope that helped you.