Przeglądaj źródła

HPCC-20098 Fail session unlock if modified and return modified status

Fail an unlock session request if session modified unless force
flag is set. Return modified status of environment for a requests
returning status.

Signed-off-by: Ken Rowland <kenneth.rowland@lexisnexisrisk.com>
Ken Rowland 7 lat temu
rodzic
commit
675b002a91

+ 2 - 0
esp/scm/ws_config2.ecm

@@ -41,6 +41,7 @@ ESPresponse [exceptions_inline] EmptyResponse
 
 ESPresponse StatusResponse
 {
+    bool EnvironmentModified;
     ESPstruct StatusType Status;
 };
 
@@ -329,6 +330,7 @@ ESPrequest UnlockSessionRequest
 {
     string SessionId;
     string SessionLockKey;
+    bool   RejectIfModified(true);
 };
 
 

+ 8 - 0
esp/services/ws_config2/ws_config2Service.cpp

@@ -316,6 +316,11 @@ bool Cws_config2Ex::onUnlockSession(IEspContext &context, IEspUnlockSessionReque
 {
     ConfigMgrSession *pSession = getConfigSessionForUpdate(req.getSessionId(), req.getSessionLockKey());
 
+    if (pSession->modified && req.getRejectIfModified())
+    {
+        throw MakeStringException(CFGMGR_ERROR_ENVIRONMENT_LOCKING, "Error unlocking the session, environment has been modified. Please save first.");
+    }
+
     if (!pSession->unlock(req.getSessionLockKey()))
     {
         throw MakeStringException(CFGMGR_ERROR_ENVIRONMENT_LOCKING, "Error unlocking the session");
@@ -395,6 +400,7 @@ bool Cws_config2Ex::onRemoveNode(IEspContext &context, IEspRemoveNodeRequest &re
     pSession->modified = true;
     pSession->m_pEnvMgr->validate(status, false);
     buildStatusResponse(status, pSession, resp.updateStatus());
+    resp.setEnvironmentModified(pSession->modified);
     return true;
 }
 
@@ -407,6 +413,7 @@ bool Cws_config2Ex::onValidateEnvironment(IEspContext &context, IEspValidateEnvi
 
     pSession->m_pEnvMgr->validate(status, req.getIncludeHiddenNodes());
     buildStatusResponse(status, pSession, resp.updateStatus());
+    resp.setEnvironmentModified(pSession->modified);
     return true;
 }
 
@@ -442,6 +449,7 @@ bool Cws_config2Ex::onSetValues(IEspContext &context, IEspSetValuesRequest &req,
     pNode->setAttributeValues(values, status, allowInvalid, forceCreate);
     pSession->modified = true;
     buildStatusResponse(status, pSession, resp.updateStatus());
+    resp.setEnvironmentModified(pSession->modified);
     return true;
 }