Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-7165

CAConfig Impl: Potential data loss when saving multiple nested configuration lists

    XMLWordPrintableJSON

Details

    Description

      as reported in https://wcm-io.atlassian.net/browse/WCON-39:

      The following porblem has been discovered by one of our teammates. Consider the following issue.

      • Config A has a list of objects let's call B, where B is an array of objects, whereeach object in B is a label and list of objects let's call it C.
      • Create for each item in B, a list of items then save.
      • Try to update the label in any item in B, as a result each sublist under each object in B, will be deleted as a result.
        *
        *The problem is i found it in code, you delete all items in the first level, and as a result in the second level.
         public boolean persistConfigurationCollection(ResourceResolver resourceResolver, String configResourceCollectionParentPath, ConfigurationCollectionPersistData data) {
                if (!this.config.enabled()) {
                    return false;
                } else {
                    Resource configResourceParent = this.getOrCreateResource(resourceResolver, configResourceCollectionParentPath, data.getProperties());
        // you delete below all list of items. and subnodes of it
                    this.deleteChildren(configResourceParent);
                    Iterator var5 = data.getItems().iterator();
        
                    while(var5.hasNext()) {
                        ConfigurationPersistData item = (ConfigurationPersistData)var5.next();
                        String path = configResourceParent.getPath() + "/" + item.getCollectionItemName();
                        this.getOrCreateResource(resourceResolver, path, item.getProperties());
                    }
        
                    this.commit(resourceResolver, configResourceCollectionParentPath);
                    return true;
                }
            }
        
        

      Attachments

        Activity

          People

            sseifert Stefan Seifert
            sseifert Stefan Seifert
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: