alfrescoalfresco-webscriptsopencmis

How to get more than 1000 Documents By Using CMIS Query


By using CMIS Query i am only able to fetch 1000 documents. But i want to fetch all the documents available in the repository.

I read some solution regarding this, that we can make some configuration in repository.properties file and get the documents.

But here my question is, can we do it through our Code in CMIS, because i am accessing production repository. and to make the change in repository.properties file i need some down time from business users. that is not possible in my case.

So i am looking for some programmatic solution.

Can anyone please help me?

Thanks in Advance..


Solution

  • 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.