Browse Source

HPCC-15172 PM-validate should preprocess the PM the same way PM add does

Ids should be lowercased, '~'s removed, etc.

Signed-off-by: Anthony Fishbeck <anthony.fishbeck@lexisnexis.com>
Anthony Fishbeck 9 năm trước cách đây
mục cha
commit
9966a24732
1 tập tin đã thay đổi với 37 bổ sung29 xóa
  1. 37 29
      esp/services/ws_packageprocess/ws_packageprocessService.cpp

+ 37 - 29
esp/services/ws_packageprocess/ws_packageprocessService.cpp

@@ -182,6 +182,41 @@ void makePackageActive(IPropertyTree *pkgSet, IPropertyTree *psEntryNew, const c
         psEntryNew->setPropBool("@active", activate);
 }
 
+void fixPackageMapFileIds(IPropertyTree *pm, bool preloadAll)
+{
+    if (!pm)
+        return;
+    Owned<IPropertyTreeIterator> iter = pm->getElements("Package");
+    ForEach(*iter)
+    {
+        IPropertyTree &item = iter->query();
+        if (preloadAll)
+            item.setPropBool("@preload", true);
+        Owned<IPropertyTreeIterator> superFiles = item.getElements("SuperFile");
+        ForEach(*superFiles)
+        {
+            IPropertyTree &superFile = superFiles->query();
+            StringBuffer lc(superFile.queryProp("@id"));
+            const char *id = lc.toLowerCase().str();
+            if (*id == '~')
+                id++;
+            superFile.setProp("@id", id);
+
+            Owned<IPropertyTreeIterator> subFiles = superFile.getElements("SubFile");
+            ForEach(*subFiles)
+            {
+                IPropertyTree &subFile = subFiles->query();
+                id = subFile.queryProp("@value");
+                if (id && *id == '~')
+                {
+                    StringAttr value(id+1);
+                    subFile.setProp("@value", value.get());
+                }
+            }
+        }
+    }
+}
+
 //////////////////////////////////////////////////////////
 
 #define PKGADD_DFS_OVERWRITE    0x0001
@@ -308,35 +343,7 @@ public:
         StringBuffer lcPmid(pmid);
         pmid = lcPmid.toLowerCase().str();
 
-        Owned<IPropertyTreeIterator> iter = pmPart->getElements("Package");
-        ForEach(*iter)
-        {
-            IPropertyTree &item = iter->query();
-            if (checkFlag(PKGADD_PRELOAD_ALL))
-                item.setPropBool("@preload", true);
-            Owned<IPropertyTreeIterator> superFiles = item.getElements("SuperFile");
-            ForEach(*superFiles)
-            {
-                IPropertyTree &superFile = superFiles->query();
-                StringBuffer lc(superFile.queryProp("@id"));
-                const char *id = lc.toLowerCase().str();
-                if (*id == '~')
-                    id++;
-                superFile.setProp("@id", id);
-
-                Owned<IPropertyTreeIterator> subFiles = superFile.getElements("SubFile");
-                ForEach(*subFiles)
-                {
-                    IPropertyTree &subFile = subFiles->query();
-                    id = subFile.queryProp("@value");
-                    if (id && *id == '~')
-                    {
-                        StringAttr value(id+1);
-                        subFile.setProp("@value", value.get());
-                    }
-                }
-            }
-        }
+        fixPackageMapFileIds(pmPart, checkFlag(PKGADD_PRELOAD_ALL));
     }
     void cloneDfsInfo(unsigned updateFlags, StringArray &filesNotFound)
     {
@@ -957,6 +964,7 @@ bool CWsPackageProcessEx::onValidatePackage(IEspContext &context, IEspValidatePa
         mapTree.setown(createPTreeFromXMLString(info));
         if (!mapTree)
             throw MakeStringException(PKG_LOAD_PACKAGEMAP_FAILED, "Error processing package file content");
+        fixPackageMapFileIds(mapTree, false);
     }
     else
     {