cancel
Showing results for 
Search instead for 
Did you mean: 

Problems updating a folder Name!

robobot
Champ in-the-making
Champ in-the-making
Hello,
strage Problem: when i use the following method to rename a folder in alfresco the new name is shown in alfresco web application. but when i try to get files in these folder, it says the new folder path does not exist. there is still the old folderpath after the update :?:
please may anybody help me.


   public void updateFolderName (String folderPath, String newFoldername){

     UpdateResult [] result = null; 
     final Reference reference = new Reference(STORE, null, folderPath);    
     final Predicate p = new Predicate(new Reference[]{reference},null,null);
     final CMLUpdate updateFolder = new CMLUpdate( new NamedValue[]{Utils.createNamedValue(Constants.PROP_NAME, newFoldername),p,null);
    
     CML cml = new CML();
     cml.setUpdate(new CMLUpdate[]{updateFolder});         
 
     try {
       result = WebServiceFactory.getRepositoryService().update(cml);
       //getting the old path!!
       System.out.println("path: " + result[0].getSource().getPath());
     } catch ( RepositoryFault rf ) {
       rf.printStackTrace();
     } catch ( RemoteException re ) {
       re.printStackTrace();
     }
    }
1 REPLY 1

derek
Star Contributor
Star Contributor
Hi,
Check that the persisted data matches the result you are getting using the Node Browser.  In Alfresco, node properties are independent of the node path i.e. the cm:name property is not given any special treatment as such.  There are interfaces (e.g. FileFolderService) and clients that will modify a node's path if the name changes, but it's not something that happens automatically.  If your business logic requires it - or you're interacting with a client that mandates it - then you will have to modify the path, too.
Regards