Przeglądaj źródła

Merge pull request #10801 from rpastrana/HPCC-18881-esdl-report-error

HPCC-18881 WsEDSLConfig should report definition publish failures

Reviewed-By: Kevin Wang <kevin.wang@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 7 lat temu
rodzic
commit
4035f00062

+ 19 - 8
esp/services/ws_esdlconfig/ws_esdlconfigservice.cpp

@@ -248,7 +248,7 @@ IPropertyTree * CWsESDLConfigEx::getESDLDefinitionRegistry(const char * wsEclId,
     return (conn) ? conn->getRoot() : NULL;
 }
 
-void CWsESDLConfigEx::addESDLDefinition(IPropertyTree * queryRegistry, const char * name, IPropertyTree *definitionInfo, StringBuffer &newId, unsigned &newSeq, const char *userid, bool deleteprev)
+bool CWsESDLConfigEx::addESDLDefinition(IPropertyTree * queryRegistry, const char * name, IPropertyTree *definitionInfo, StringBuffer &newId, unsigned &newSeq, const char *userid, bool deleteprev, StringBuffer & message)
 {
     StringBuffer lcName(name);
     lcName.toLowerCase();
@@ -285,14 +285,16 @@ void CWsESDLConfigEx::addESDLDefinition(IPropertyTree * queryRegistry, const cha
             }
             else
             {
-                DBGLOG("Could not overwrite Definition: '%s.%d'", name, newSeq);
-                return;
+                message.setf("Could not overwrite Definition: '%s.%d'", name, newSeq);
+                ESPLOG(LogMin, "%s", message.str());
+                return false;
             }
         }
         else
         {
-            DBGLOG("Will not delete previous ESDL definition version because it is referenced in an ESDL binding.");
-            return;
+            message.setf("Will not delete previous ESDL definition version because it is referenced in an ESDL binding.");
+            ESPLOG(LogMin, "%s", message.str());
+            return false;
         }
     }
 
@@ -321,6 +323,7 @@ void CWsESDLConfigEx::addESDLDefinition(IPropertyTree * queryRegistry, const cha
         definitionInfo->setProp("@created",dt.getString(str).str());
 
     queryRegistry->addPropTree(ESDL_DEF_ENTRY, LINK(definitionInfo));
+    return true;
 }
 
 bool CWsESDLConfigEx::existsESDLDefinition(const char * servicename, unsigned ver)
@@ -500,9 +503,17 @@ bool CWsESDLConfigEx::onPublishESDLDefinition(IEspContext &context, IEspPublishE
 
             if (queryRegistry != NULL)
             {
-                addESDLDefinition(queryRegistry, service.get(), serviceXMLTree.get(), newqueryid, newseq, user, deletePrevious);
-                if (newseq)
-                    resp.setEsdlVersion(newseq);
+                if (addESDLDefinition(queryRegistry, service.get(), serviceXMLTree.get(), newqueryid, newseq, user, deletePrevious, msg))
+                {
+                    if (newseq)
+                        resp.setEsdlVersion(newseq);
+                }
+                else
+                {
+                    resp.updateStatus().setCode(-1);
+                    resp.updateStatus().setDescription(msg.str());
+                    return false;
+                }
             }
             else
             {

+ 1 - 1
esp/services/ws_esdlconfig/ws_esdlconfigservice.hpp

@@ -44,7 +44,7 @@ public:
     static int publishESDLBinding(const char * bindingName, IPropertyTree * methodsConfig, const char * espProcName, const char * espPort, const char * esdlDefinitionName, int esdlDefinitionVersion, const char * esdlServiceName, StringBuffer & message, bool overwrite, const char * user);
     static IPropertyTree * getEspProcessRegistry(const char * espprocname, const char * espbingingport, const char * servicename);
     static IPropertyTree * getESDLDefinitionRegistry(const char * wsEclId, bool readonly);
-    static void addESDLDefinition(IPropertyTree * queryRegistry, const char * name, IPropertyTree * definitionInfo, StringBuffer &newId, unsigned &newSeq, const char *userid, bool deleteprev);
+    static bool addESDLDefinition(IPropertyTree * queryRegistry, const char * name, IPropertyTree * definitionInfo, StringBuffer &newId, unsigned &newSeq, const char *userid, bool deleteprev, StringBuffer & message);
     static int publishESDLMethod(const char * espProcName, const char * espBindingName, const char * srvDefId, const char * methodName, IPropertyTree * attributesTree, bool readonly, StringBuffer & message);
     static int getBindingXML(const char * espProcName, const char * espBindingName, StringBuffer & bindingXml, StringBuffer & msg);
     static IPropertyTree * getBindingTree(const char * espProcName, const char * espBindingName, StringBuffer & msg);