[Libreoffice-commits] online.git: loolwsd/DocumentBroker.hpp loolwsd/LOOLWSD.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Mar 14 03:12:06 UTC 2016


 loolwsd/DocumentBroker.hpp |   23 +++++++++++++++++------
 loolwsd/LOOLWSD.cpp        |    2 +-
 2 files changed, 18 insertions(+), 7 deletions(-)

New commits:
commit c0cf48f5ac885b878afd0b67c63332bdc91a94b8
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sat Mar 12 20:14:32 2016 -0500

    loolwsd: jailRoot moved in DocumentBroker
    
    Change-Id: Ic9dfce0cb0f2f87fae9a918df500c89673f15716
    Reviewed-on: https://gerrit.libreoffice.org/23217
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/DocumentBroker.hpp b/loolwsd/DocumentBroker.hpp
index e78ccc3..e2cd9ee 100644
--- a/loolwsd/DocumentBroker.hpp
+++ b/loolwsd/DocumentBroker.hpp
@@ -57,7 +57,7 @@ public:
     }
 
     static
-    std::shared_ptr<DocumentBroker> create(const std::string& uri)
+    std::shared_ptr<DocumentBroker> create(const std::string& uri, const std::string& childRoot)
     {
         std::string decodedUri;
         Poco::URI::decode(uri, decodedUri);
@@ -75,18 +75,18 @@ public:
             throw std::runtime_error("Invalid URI.");
         }
 
-        return create(uriPublic);
+        return create(uriPublic, childRoot);
     }
 
     static
-    std::shared_ptr<DocumentBroker> create(const Poco::URI& uriPublic)
+    std::shared_ptr<DocumentBroker> create(const Poco::URI& uriPublic, const std::string& childRoot)
     {
         Log::info("Creating DocumentBroker for uri: " + uriPublic.toString());
 
         std::string docKey;
         Poco::URI::encode(uriPublic.getPath(), "", docKey);
 
-        return std::shared_ptr<DocumentBroker>(new DocumentBroker(uriPublic, docKey));
+        return std::shared_ptr<DocumentBroker>(new DocumentBroker(uriPublic, docKey, childRoot));
     }
 
     ~DocumentBroker()
@@ -148,18 +148,29 @@ public:
     const std::string& getJailId() const { return _jailId; }
     const std::string& getDocKey() const { return _docKey; }
 
+    std::string getJailRoot() const
+    {
+        assert(!_jailId.empty());
+        return Poco::Path(_childRoot, _jailId).toString();
+    }
+
 private:
     DocumentBroker(const Poco::URI& uriPublic,
-                   const std::string& docKey) :
+                   const std::string& docKey,
+                   const std::string& childRoot) :
        _uriPublic(uriPublic),
-       _docKey(docKey)
+       _docKey(docKey),
+       _childRoot(childRoot)
     {
+        assert(!_docKey.empty());
+        assert(!_childRoot.empty());
         Log::info("DocumentBroker [" + _uriPublic.toString() + "] created.");
     }
 
 private:
     const Poco::URI _uriPublic;
     const std::string _docKey;
+    const std::string _childRoot;
     Poco::URI _uriJailed;
     std::string _jailId;
     std::unique_ptr<StorageBase> _storage;
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index d382e35..28b1a8e 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -505,7 +505,7 @@ private:
         // request.getCookies(cookies);
         // Log::info("Cookie: " + cookies.get("PHPSESSID", ""));
 
-        auto docBroker = DocumentBroker::create(request.getURI());
+        auto docBroker = DocumentBroker::create(request.getURI(), LOOLWSD::ChildRoot);
         const auto docKey = docBroker->getDocKey();
 
         {


More information about the Libreoffice-commits mailing list