loleaflet/dist/errormessages.js |    1 +
 loleaflet/src/core/Socket.js    |    3 +++
 wsd/DocumentBroker.cpp          |    5 +++++
 wsd/Storage.cpp                 |    4 ++++
 wsd/Storage.hpp                 |    1 +
 5 files changed, 14 insertions(+)

New commits:
commit d840e8720a2ba45ae981b53e5a06b4d28f847314
Author: Pranav Kant <pran...@collabora.co.uk>
Date:   Wed May 31 11:51:12 2017 +0530

    Handle WOPI PutFile unauthorized access token
    
    Change-Id: I29ee8cc0c9f3ea42f70628eca6f74d161d1a38f9

diff --git a/loleaflet/dist/errormessages.js b/loleaflet/dist/errormessages.js
index 89f31fc7..8ea1185c 100644
--- a/loleaflet/dist/errormessages.js
+++ b/loleaflet/dist/errormessages.js
@@ -12,5 +12,6 @@ exports.faileddocloading = _('Failed to load the document. 
Please ensure the fil
 exports.storage = {
        loadfailed: _('Failed to read document from storage. Please contact 
your storage server (%storageserver) administrator.'),
        savediskfull: _('Save failed due to no disk space left on storage 
server. Document will now be read-only. Please contact the server 
(%storageserver) administrator to continue editing.'),
+       saveunauthorized: _('Document cannot be saved to storage server 
(%storageserver) due to expired or invalid access token. Refresh your session 
to not to lose your work.'),
        savefailed: _('Document cannot be saved to storage. Check your 
permissions or contact the storage server (%storageserver) administrator.')
 };
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 25f5f83f..fdce2a54 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -320,6 +320,9 @@ L.Socket = L.Class.extend({
                        else if (command.errorKind === 'savefailed') {
                                storageError = errorMessages.storage.savefailed;
                        }
+                       else if (command.errorKind === 'saveunauthorized') {
+                               storageError = 
errorMessages.storage.saveunauthorized;
+                       }
                        else if (command.errorKind === 'loadfailed') {
                                storageError = errorMessages.storage.loadfailed;
                                // Since this is a document load failure, wsd 
will disconnect the socket anyway,
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 7e2a1669..e5e8a19c 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -647,6 +647,11 @@ bool DocumentBroker::saveToStorageInternal(const 
std::string& sessionId,
             sessionIt.second->sendTextFrame("error: cmd=storage 
kind=savediskfull");
         }
     }
+    else if (storageSaveResult == StorageBase::SaveResult::UNAUTHORIZED)
+    {
+        LOG_ERR("Cannot save docKey [" << _docKey << "] to storage URI [" << 
uri << "]. Invalid or expired access token. Notifying client.");
+        it->second->sendTextFrame("error: cmd=storage kind=saveunauthorized");
+    }
     else if (storageSaveResult == StorageBase::SaveResult::FAILED)
     {
         //TODO: Should we notify all clients?
diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 3ade24e2..a698b04f 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -662,6 +662,10 @@ StorageBase::SaveResult 
WopiStorage::saveLocalFileToStorage(const std::string& a
         {
             saveResult = StorageBase::SaveResult::DISKFULL;
         }
+        else if (response.getStatus() == 
Poco::Net::HTTPResponse::HTTP_UNAUTHORIZED)
+        {
+            saveResult = StorageBase::SaveResult::UNAUTHORIZED;
+        }
     }
     catch(const Poco::Exception& pexc)
     {
diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp
index e786f5b2..34b56de3 100644
--- a/wsd/Storage.hpp
+++ b/wsd/Storage.hpp
@@ -57,6 +57,7 @@ public:
     {
         OK,
         DISKFULL,
+        UNAUTHORIZED,
         FAILED
     };
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to