javafilenet-p8filenetfilenet-content-engine

Fetch FileStorageArea in Filenet with path [Document Moving]


I am a student and I'm new to Filenet. I am trying to do the test code on file moving.

Document doc = Factory.Document.getInstance(os, ClassNames.DOCUMENT, new Id("{33074B6E-FD19-4C0D-96FC-D809633D35BF}") );
FileStorageArea newDocClassFSA = Factory.FileStorageArea.fetchInstance(os, new Id("{3C6CEE68-D8CC-44A5-AEE7-CADE9752AA77}"), null );

doc.moveContent(dsa);
doc.save(RefreshMode.REFRESH);

The thing is that I can fetch the document by its path like this ,

doc = Factory.Document.fetchInstance(os, "/DEMO/MASTERFILE/ZONE-X/Org.No-XXXXX/XXXX-X-XXXX-X.TIF",null);

but I can't fetch the StorageArea by the path, it only takes ID. Is there a way to move a file easily than this? How can I get ID with path without using queries?


Solution

  • You can access the ID of the document using the path:

            //Get ID of the Document 
            StringBuffer propertyNames = new StringBuffer();
            propertyNames.append(PropertyNames.ID);
            propertyNames.append(" ");
            propertyNames.append(PropertyNames.PATH_NAME);
    
            PropertyFilter pf=new  PropertyFilter();
    
            FilterElement felement= new FilterElement(Integer.valueOf(0),Long.valueOf(0),Boolean.TRUE,propertyNames.toString(),Integer.valueOf(0));
            pf.addIncludeProperty(felement);
    
            Document document = Factory.Document.fetchInstance(os, ruta, pf );
    
            idDocument = document.get_Id().toString();
    

    and in the idDocument string you have it. Hope it helps.