فهرست منبع

gh-2196 Ecl package needs to return error messages to user

fixes gh-2196

Signed-off-by: Stuart Ort <stuart.ort@lexisnexis.com>
Stuart Ort 13 سال پیش
والد
کامیت
9f49238178

+ 40 - 19
ecl/ecl-package/ecl-package.cpp

@@ -89,6 +89,9 @@ public:
         request->setPackageMapName(optPackageMap);
         request->setPackageMapName(optPackageMap);
 
 
         Owned<IClientActivatePackageResponse> resp = packageProcessClient->ActivatePackage(request);
         Owned<IClientActivatePackageResponse> resp = packageProcessClient->ActivatePackage(request);
+        if (resp->getExceptions().ordinality())
+            outputMultiExceptions(resp->getExceptions());
+
         return 0;
         return 0;
     }
     }
     virtual void usage()
     virtual void usage()
@@ -164,6 +167,9 @@ public:
         request->setPackageMapName(optPackageMap);
         request->setPackageMapName(optPackageMap);
 
 
         Owned<IClientDeActivatePackageResponse> resp = packageProcessClient->DeActivatePackage(request);
         Owned<IClientDeActivatePackageResponse> resp = packageProcessClient->DeActivatePackage(request);
+        if (resp->getExceptions().ordinality())
+            outputMultiExceptions(resp->getExceptions());
+
         return 0;
         return 0;
     }
     }
     virtual void usage()
     virtual void usage()
@@ -230,30 +236,33 @@ public:
         request->setCluster(optCluster);
         request->setCluster(optCluster);
 
 
         Owned<IClientListPackageResponse> resp = packageProcessClient->ListPackage(request);
         Owned<IClientListPackageResponse> resp = packageProcessClient->ListPackage(request);
-
-        IArrayOf<IConstPackageListMapData> &pkgMapInfo = resp->getPkgListMapData();
-        unsigned int num = pkgMapInfo.ordinality();
-
-        for (unsigned i=0; i<num; i++)
+        if (resp->getExceptions().ordinality())
+            outputMultiExceptions(resp->getExceptions());
+        else
         {
         {
-            IConstPackageListMapData& req = pkgMapInfo.item(i);
-            const char *id = req.getId();
-            printf("\nPackage Name = %s\n", id);
-            IArrayOf<IConstPackageListData> &pkgInfo = req.getPkgListData();
+            IArrayOf<IConstPackageListMapData> &pkgMapInfo = resp->getPkgListMapData();
+            unsigned int num = pkgMapInfo.ordinality();
 
 
-            unsigned int numPkgs = pkgInfo.ordinality();
-            for (unsigned int j = 0; j <numPkgs; j++)
+            for (unsigned i=0; i<num; i++)
             {
             {
-                IConstPackageListData& req = pkgInfo.item(j);
+                IConstPackageListMapData& req = pkgMapInfo.item(i);
                 const char *id = req.getId();
                 const char *id = req.getId();
-                const char *queries = req.getQueries();
-                if (queries && *queries)
-                    printf("\t\tid = %s  queries = %s\n", id, queries);
-                else
-                    printf("\t\tid = %s\n", id);
+                printf("\nPackage Name = %s\n", id);
+                IArrayOf<IConstPackageListData> &pkgInfo = req.getPkgListData();
+
+                unsigned int numPkgs = pkgInfo.ordinality();
+                for (unsigned int j = 0; j <numPkgs; j++)
+                {
+                    IConstPackageListData& req = pkgInfo.item(j);
+                    const char *id = req.getId();
+                    const char *queries = req.getQueries();
+                    if (queries && *queries)
+                        printf("\t\tid = %s  queries = %s\n", id, queries);
+                    else
+                        printf("\t\tid = %s\n", id);
+                }
             }
             }
         }
         }
-
         return 0;
         return 0;
     }
     }
     virtual void usage()
     virtual void usage()
@@ -331,7 +340,10 @@ public:
         request->setCluster(optCluster);
         request->setCluster(optCluster);
 
 
         Owned<IClientGetPackageResponse> resp = packageProcessClient->GetPackage(request);
         Owned<IClientGetPackageResponse> resp = packageProcessClient->GetPackage(request);
-        printf("%s", resp->getInfo());
+        if (resp->getExceptions().ordinality())
+            outputMultiExceptions(resp->getExceptions());
+        else
+            printf("%s", resp->getInfo());
         return 0;
         return 0;
     }
     }
     virtual void usage()
     virtual void usage()
@@ -410,6 +422,9 @@ public:
         request->setPackageName(optFileName);
         request->setPackageName(optFileName);
 
 
         Owned<IClientDeletePackageResponse> resp = packageProcessClient->DeletePackage(request);
         Owned<IClientDeletePackageResponse> resp = packageProcessClient->DeletePackage(request);
+        if (resp->getExceptions().ordinality())
+            outputMultiExceptions(resp->getExceptions());
+
         return 0;
         return 0;
     }
     }
 
 
@@ -497,6 +512,9 @@ public:
         request->setOverWrite(optOverWrite);
         request->setOverWrite(optOverWrite);
 
 
         Owned<IClientAddPackageResponse> resp = packageProcessClient->AddPackage(request);
         Owned<IClientAddPackageResponse> resp = packageProcessClient->AddPackage(request);
+        if (resp->getExceptions().ordinality())
+            outputMultiExceptions(resp->getExceptions());
+
         return 0;
         return 0;
     }
     }
 
 
@@ -593,6 +611,9 @@ public:
             request->setDaliIp(optDaliIp.get());
             request->setDaliIp(optDaliIp.get());
 
 
         Owned<IClientCopyFilesResponse> resp = packageProcessClient->CopyFiles(request);
         Owned<IClientCopyFilesResponse> resp = packageProcessClient->CopyFiles(request);
+        if (resp->getExceptions().ordinality())
+            outputMultiExceptions(resp->getExceptions());
+
         return 0;
         return 0;
     }
     }
 
 

+ 7 - 7
esp/scm/ws_packageprocess.ecm

@@ -29,7 +29,7 @@ ESPrequest AddPackageRequest
 };
 };
 
 
 
 
-ESPresponse AddPackageResponse
+ESPresponse [exceptions_inline] AddPackageResponse
 {
 {
     ESPstruct BasePackageStatus status;
     ESPstruct BasePackageStatus status;
 };
 };
@@ -40,7 +40,7 @@ ESPrequest DeletePackageRequest
     string PackageName;
     string PackageName;
 };
 };
 
 
-ESPresponse DeletePackageResponse
+ESPresponse [exceptions_inline] DeletePackageResponse
 {
 {
     ESPstruct BasePackageStatus status;
     ESPstruct BasePackageStatus status;
 };
 };
@@ -51,7 +51,7 @@ ESPrequest ActivatePackageRequest
     string PackageMapName;
     string PackageMapName;
 };
 };
 
 
-ESPresponse ActivatePackageResponse
+ESPresponse [exceptions_inline] ActivatePackageResponse
 {
 {
     ESPstruct BasePackageStatus status;
     ESPstruct BasePackageStatus status;
 };
 };
@@ -62,7 +62,7 @@ ESPrequest DeActivatePackageRequest
     string PackageMapName;
     string PackageMapName;
 };
 };
 
 
-ESPresponse DeActivatePackageResponse
+ESPresponse [exceptions_inline] DeActivatePackageResponse
 {
 {
     ESPstruct BasePackageStatus status;
     ESPstruct BasePackageStatus status;
 };
 };
@@ -73,7 +73,7 @@ ESPrequest GetPackageRequest
     string PackageName;
     string PackageName;
 };
 };
 
 
-ESPresponse GetPackageResponse
+ESPresponse [exceptions_inline] GetPackageResponse
 {
 {
     ESPstruct BasePackageStatus status;
     ESPstruct BasePackageStatus status;
     string Info;
     string Info;
@@ -96,7 +96,7 @@ ESPstruct PackageListMapData
     ESParray<ESPstruct PackageListData> PkgListData;
     ESParray<ESPstruct PackageListData> PkgListData;
 };
 };
 
 
-ESPresponse ListPackageResponse
+ESPresponse [exceptions_inline] ListPackageResponse
 {
 {
     ESPstruct BasePackageStatus status;
     ESPstruct BasePackageStatus status;
     ESParray<ESPstruct PackageListMapData> PkgListMapData;
     ESParray<ESPstruct PackageListMapData> PkgListMapData;
@@ -112,7 +112,7 @@ ESPrequest CopyFilesRequest
 };
 };
 
 
 
 
-ESPresponse CopyFilesResponse
+ESPresponse [exceptions_inline] CopyFilesResponse
 {
 {
     ESPstruct BasePackageStatus status;
     ESPstruct BasePackageStatus status;
 };
 };

+ 1 - 0
esp/services/ws_packageprocess/CMakeLists.txt

@@ -21,6 +21,7 @@ set (    SRCS
          ws_packageprocessPlugin.cpp
          ws_packageprocessPlugin.cpp
          ws_packageprocessService.cpp
          ws_packageprocessService.cpp
          ws_packageprocessService.hpp
          ws_packageprocessService.hpp
+         packageprocess_errors.h
     )
     )
 
 
 include_directories (
 include_directories (

+ 33 - 0
esp/services/ws_packageprocess/packageprocess_errors.h

@@ -0,0 +1,33 @@
+/*##############################################################################
+
+    Copyright (C) 2011 HPCC Systems.
+
+    All rights reserved. This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU Affero General Public License as
+    published by the Free Software Foundation, either version 3 of the
+    License, or (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU Affero General Public License for more details.
+
+    You should have received a copy of the GNU Affero General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+############################################################################## */
+
+#ifndef PACKAGEPROCESS_ERRORS_H
+#define PACKAGEPROCESS_ERRORS_H
+
+#include "errorlist.h"
+
+#define PKG_NAME_EXISTS   PKG_PROCESS_ERROR_START
+#define PKG_MISSING_PARAM   PKG_PROCESS_ERROR_START+1
+#define PKG_DALI_LOOKUP_ERROR    PKG_PROCESS_ERROR_START+2
+#define PKG_MISSING_DALI_LOOKUP_IP  PKG_PROCESS_ERROR_START+3
+#define PKG_SET_NOT_DEFINED   PKG_PROCESS_ERROR_START+4
+#define PKG_ACTIVATE_NOT_FOUND   PKG_PROCESS_ERROR_START+5
+#define PKG_DEACTIVATE_NOT_FOUND   PKG_PROCESS_ERROR_START+6
+#define PKG_DELETE_NOT_FOUND   PKG_PROCESS_ERROR_START+7
+
+#endif

+ 32 - 21
esp/services/ws_packageprocess/ws_packageprocessService.cpp

@@ -1,5 +1,19 @@
 /*##############################################################################
 /*##############################################################################
-Copyright (C) 2011 HPCC Systems.
+
+    Copyright (C) 2011 HPCC Systems.
+
+    All rights reserved. This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU Affero General Public License as
+    published by the Free Software Foundation, either version 3 of the
+    License, or (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU Affero General Public License for more details.
+
+    You should have received a copy of the GNU Affero General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ############################################################################## */
 ############################################################################## */
 
 
 #pragma warning (disable : 4786)
 #pragma warning (disable : 4786)
@@ -11,6 +25,7 @@ Copyright (C) 2011 HPCC Systems.
 #include "dfuutil.hpp"
 #include "dfuutil.hpp"
 #include "ws_fs.hpp"
 #include "ws_fs.hpp"
 #include "ws_workunits.hpp"
 #include "ws_workunits.hpp"
+#include "packageprocess_errors.h"
 
 
 #define SDS_LOCK_TIMEOUT (5*60*1000) // 5mins, 30s a bit short
 #define SDS_LOCK_TIMEOUT (5*60*1000) // 5mins, 30s a bit short
 
 
@@ -58,7 +73,7 @@ IPropertyTree *getPkgSetRegistry(const char *setName, bool readonly)
 
 
         conn.setown(querySDS().connect(xpath.str(), myProcessSession(), RTM_LOCK_WRITE, SDS_LOCK_TIMEOUT));
         conn.setown(querySDS().connect(xpath.str(), myProcessSession(), RTM_LOCK_WRITE, SDS_LOCK_TIMEOUT));
         if (!conn)
         if (!conn)
-            throwUnexpected();
+            throw MakeStringException(PKG_DALI_LOOKUP_ERROR, "Unable to retrieve package information from dali %s", xpath.str());
     }
     }
 
 
     return conn->getRoot();
     return conn->getRoot();
@@ -167,9 +182,7 @@ void addPackageMapInfo(IPropertyTree *pkgSetRegistry, const char *setName, const
     IPropertyTree *mapTree = root->queryPropTree(xpath);
     IPropertyTree *mapTree = root->queryPropTree(xpath);
 
 
     if (!overWrite && (pkgRegTree || mapTree))
     if (!overWrite && (pkgRegTree || mapTree))
-    {
-        throw MakeStringException(0, "Package name %s already exists, either delete it or specify overwrite", lcName.str());
-    }
+        throw MakeStringException(PKG_NAME_EXISTS, "Package name %s already exists, either delete it or specify overwrite", lcName.str());
 
 
     if (mapTree)
     if (mapTree)
         root->removeTree(mapTree);
         root->removeTree(mapTree);
@@ -238,8 +251,7 @@ void copyPackageSubFiles(IPropertyTree *packageInfo, const char *process, const
         if (lookupDaliIp.length() == 0)
         if (lookupDaliIp.length() == 0)
         {
         {
             StringAttr superfile(item.queryProp("@id"));
             StringAttr superfile(item.queryProp("@id"));
-            DBGLOG("Could not lookup SubFiles in package %s because no remote dali ip was specified", superfile.get());
-            return;
+            throw MakeStringException(PKG_MISSING_DALI_LOOKUP_IP, "Could not lookup SubFiles in package %s because no remote dali ip was specified", superfile.get());
         }
         }
         Owned<IPropertyTreeIterator> super_iter = item.getElements("SuperFile");
         Owned<IPropertyTreeIterator> super_iter = item.getElements("SuperFile");
         ForEach(*super_iter)
         ForEach(*super_iter)
@@ -298,7 +310,7 @@ void listPkgInfo(const char *cluster, IArrayOf<IConstPackageListMapData>* result
     StringBuffer info;
     StringBuffer info;
     Owned<IRemoteConnection> globalLock = querySDS().connect("/PackageMaps/", myProcessSession(), RTM_LOCK_WRITE|RTM_CREATE_QUERY, SDS_LOCK_TIMEOUT);
     Owned<IRemoteConnection> globalLock = querySDS().connect("/PackageMaps/", myProcessSession(), RTM_LOCK_WRITE|RTM_CREATE_QUERY, SDS_LOCK_TIMEOUT);
     if (!globalLock)
     if (!globalLock)
-        return;
+        throw MakeStringException(PKG_DALI_LOOKUP_ERROR, "Unable to retrieve package information from dali /PackageMaps");
     IPropertyTree *root = globalLock->queryRoot();
     IPropertyTree *root = globalLock->queryRoot();
     if (!cluster || !*cluster)
     if (!cluster || !*cluster)
     {
     {
@@ -316,6 +328,9 @@ void listPkgInfo(const char *cluster, IArrayOf<IConstPackageListMapData>* result
     else
     else
     {
     {
         Owned<IPropertyTree> pkgSetRegistry = getPkgSetRegistry(cluster, true);
         Owned<IPropertyTree> pkgSetRegistry = getPkgSetRegistry(cluster, true);
+        if (!pkgSetRegistry)
+            throw MakeStringException(PKG_DALI_LOOKUP_ERROR, "Unable to retrieve package information from dali for cluster %s", cluster);
+
         Owned<IPropertyTreeIterator> iter = pkgSetRegistry->getElements("PackageMap");
         Owned<IPropertyTreeIterator> iter = pkgSetRegistry->getElements("PackageMap");
         info.append("<PackageMaps>");
         info.append("<PackageMaps>");
         ForEach(*iter)
         ForEach(*iter)
@@ -339,7 +354,7 @@ void getPkgInfo(const char *cluster, const char *package, StringBuffer &info)
 {
 {
     Owned<IRemoteConnection> globalLock = querySDS().connect("/PackageMaps/", myProcessSession(), RTM_LOCK_WRITE|RTM_CREATE_QUERY, SDS_LOCK_TIMEOUT);
     Owned<IRemoteConnection> globalLock = querySDS().connect("/PackageMaps/", myProcessSession(), RTM_LOCK_WRITE|RTM_CREATE_QUERY, SDS_LOCK_TIMEOUT);
     if (!globalLock)
     if (!globalLock)
-        return;
+        throw MakeStringException(PKG_DALI_LOOKUP_ERROR, "Unable to retrieve package information from dali /PackageMaps");
     IPropertyTree *root = globalLock->queryRoot();
     IPropertyTree *root = globalLock->queryRoot();
     Owned<IPropertyTree> tree = createPTree("PackageMaps");
     Owned<IPropertyTree> tree = createPTree("PackageMaps");
     if (cluster)
     if (cluster)
@@ -378,20 +393,14 @@ bool deletePkgInfo(const char *packageSetName, const char *queryset)
 {
 {
     Owned<IRemoteConnection> pkgSet = querySDS().connect("/PackageSets/", myProcessSession(), RTM_LOCK_WRITE, SDS_LOCK_TIMEOUT);
     Owned<IRemoteConnection> pkgSet = querySDS().connect("/PackageSets/", myProcessSession(), RTM_LOCK_WRITE, SDS_LOCK_TIMEOUT);
     if (!pkgSet)
     if (!pkgSet)
-    {
-        DBGLOG("No package sets defined");
-        return false;
-    }
+        throw MakeStringException(PKG_SET_NOT_DEFINED, "No package sets defined");
 
 
     IPropertyTree* packageSets = pkgSet->queryRoot();
     IPropertyTree* packageSets = pkgSet->queryRoot();
 
 
     VStringBuffer pkgSet_xpath("PackageSet[@id='%s']", queryset);
     VStringBuffer pkgSet_xpath("PackageSet[@id='%s']", queryset);
     IPropertyTree *pkgSetRegistry = packageSets->queryPropTree(pkgSet_xpath.str());
     IPropertyTree *pkgSetRegistry = packageSets->queryPropTree(pkgSet_xpath.str());
     if (!pkgSetRegistry)
     if (!pkgSetRegistry)
-    {
-        DBGLOG("No package sets defined for = %s", queryset);
-        return false;
-    }
+        throw MakeStringException(PKG_SET_NOT_DEFINED, "No package sets defined for %s", queryset);
 
 
     StringBuffer lcName(packageSetName);
     StringBuffer lcName(packageSetName);
     lcName.toLowerCase();
     lcName.toLowerCase();
@@ -399,6 +408,8 @@ bool deletePkgInfo(const char *packageSetName, const char *queryset)
     IPropertyTree *pm = pkgSetRegistry->getPropTree(xpath.str());
     IPropertyTree *pm = pkgSetRegistry->getPropTree(xpath.str());
     if (pm)
     if (pm)
         pkgSetRegistry->removeTree(pm);
         pkgSetRegistry->removeTree(pm);
+    else
+        throw MakeStringException(PKG_DELETE_NOT_FOUND, "Unable to delete %s - information not found", lcName.str());
 
 
     VStringBuffer ps_xpath("PackageSet/PackageMap[@id='%s']", lcName.str());
     VStringBuffer ps_xpath("PackageSet/PackageMap[@id='%s']", lcName.str());
 
 
@@ -420,11 +431,11 @@ bool deletePkgInfo(const char *packageSetName, const char *queryset)
 void activatePackageMapInfo(const char *packageSetName, const char *packageMap, bool activate)
 void activatePackageMapInfo(const char *packageSetName, const char *packageMap, bool activate)
 {
 {
     if (!packageSetName || !*packageSetName)
     if (!packageSetName || !*packageSetName)
-        return;
+        throw MakeStringException(PKG_SET_NOT_DEFINED, "No package sets defined");
 
 
     Owned<IRemoteConnection> globalLock = querySDS().connect("PackageSets", myProcessSession(), RTM_LOCK_WRITE|RTM_CREATE_QUERY, SDS_LOCK_TIMEOUT);
     Owned<IRemoteConnection> globalLock = querySDS().connect("PackageSets", myProcessSession(), RTM_LOCK_WRITE|RTM_CREATE_QUERY, SDS_LOCK_TIMEOUT);
     if (!globalLock)
     if (!globalLock)
-        return;
+        throw MakeStringException(PKG_DALI_LOOKUP_ERROR, "Unable to retrieve PackageSets information from dali /PackageSets");
 
 
     StringBuffer lcName(packageSetName);
     StringBuffer lcName(packageSetName);
     lcName.toLowerCase();
     lcName.toLowerCase();
@@ -432,7 +443,7 @@ void activatePackageMapInfo(const char *packageSetName, const char *packageMap,
 
 
     IPropertyTree *root = globalLock->queryRoot();
     IPropertyTree *root = globalLock->queryRoot();
     if (!root)
     if (!root)
-        return;
+        throw MakeStringException(PKG_ACTIVATE_NOT_FOUND, "Unable to retrieve PackageSet information for %s", lcName.str());
 
 
     IPropertyTree *pkgSetTree = root->queryPropTree(xpath);
     IPropertyTree *pkgSetTree = root->queryPropTree(xpath);
     if (pkgSetTree)
     if (pkgSetTree)
@@ -538,7 +549,7 @@ bool CWsPackageProcessEx::onCopyFiles(IEspContext &context, IEspCopyFilesRequest
     StringAttr lookupDaliIp(req.getDaliIp());
     StringAttr lookupDaliIp(req.getDaliIp());
 
 
     if (process.length() == 0)
     if (process.length() == 0)
-        throw MakeStringException(0, "CWsPackageProcessEx::onCopyFiles process parameter not set.");
+        throw MakeStringException(PKG_MISSING_PARAM, "CWsPackageProcessEx::onCopyFiles process parameter not set.");
 
 
     Owned<IUserDescriptor> userdesc;
     Owned<IUserDescriptor> userdesc;
     const char *user = context.queryUserId();
     const char *user = context.queryUserId();

+ 3 - 0
system/include/errorlist.h

@@ -64,6 +64,9 @@
 #define JVM_API_ERROR_START    10000
 #define JVM_API_ERROR_START    10000
 #define JVM_API_ERROR_END      10499
 #define JVM_API_ERROR_END      10499
 
 
+#define PKG_PROCESS_ERROR_START  11000
+#define PKG_PROCESS_ERROR_END    11100
+
 #define ECLWATCH_ERROR_START    20000
 #define ECLWATCH_ERROR_START    20000
 #define ECLWATCH_ERROR_END      29999
 #define ECLWATCH_ERROR_END      29999