[Libreoffice-commits] online.git: loolwsd/DocumentStoreManager.hpp loolwsd/Storage.hpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Mon Mar 14 03:01:26 UTC 2016
loolwsd/DocumentStoreManager.hpp | 24 +++++++++++++++++-------
loolwsd/Storage.hpp | 16 ++++++++--------
2 files changed, 25 insertions(+), 15 deletions(-)
New commits:
commit 9bf88691c693e34cb8eb866b1e789e5e523c56e0
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Thu Mar 10 22:01:34 2016 -0500
loolwsd: DocumentStoreManager maintains Storage instance
Change-Id: I0c86a7a7a3bb8d52a3f83570ccb4eded42ef4090
Reviewed-on: https://gerrit.libreoffice.org/23205
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/DocumentStoreManager.hpp b/loolwsd/DocumentStoreManager.hpp
index 76ae479..9369730 100644
--- a/loolwsd/DocumentStoreManager.hpp
+++ b/loolwsd/DocumentStoreManager.hpp
@@ -95,11 +95,12 @@ public:
Log::info("jailPath: " + jailPath.toString() + ", jailRoot: " + jailRoot);
auto uriJailed = uriPublic;
+ std::unique_ptr<StorageBase> storage;
if (uriPublic.isRelative() || uriPublic.getScheme() == "file")
{
Log::info("Public URI [" + uriPublic.toString() + "] is a file.");
- std::unique_ptr<StorageBase> storage(new LocalStorage(jailRoot, jailPath.toString(), uriPublic.getPath()));
- const auto localPath = storage->getLocalFilePathFromStorage();
+ storage.reset(new LocalStorage(jailRoot, jailPath.toString(), uriPublic.getPath()));
+ const auto localPath = storage->loadStorageFileToLocal();
uriJailed = Poco::URI(Poco::URI("file://"), localPath);
}
else
@@ -107,12 +108,12 @@ public:
Log::info("Public URI [" + uriPublic.toString() +
"] assuming cloud storage.");
//TODO: Configure the storage to use. For now, assume it's WOPI.
- std::unique_ptr<StorageBase> storage(new WopiStorage(jailRoot, jailPath.toString(), uriPublic.toString()));
- const auto localPath = storage->getLocalFilePathFromStorage();
+ storage.reset(new WopiStorage(jailRoot, jailPath.toString(), uriPublic.toString()));
+ const auto localPath = storage->loadStorageFileToLocal();
uriJailed = Poco::URI(Poco::URI("file://"), localPath);
}
- auto document = std::shared_ptr<DocumentStoreManager>(new DocumentStoreManager(uriPublic, uriJailed, childId));
+ auto document = std::shared_ptr<DocumentStoreManager>(new DocumentStoreManager(uriPublic, uriJailed, childId, std::move(storage)));
return document;
}
@@ -122,6 +123,11 @@ public:
Log::info("~DocumentStoreManager [" + _uriPublic.toString() + "] destroyed.");
}
+ bool save()
+ {
+ return _storage->saveLocalFileToStorage();
+ }
+
Poco::URI getPublicUri() const { return _uriPublic; }
Poco::URI getJailedUri() const { return _uriJailed; }
std::string getJailId() const { return _jailId; }
@@ -129,10 +135,12 @@ public:
private:
DocumentStoreManager(const Poco::URI& uriPublic,
const Poco::URI& uriJailed,
- const std::string& jailId) :
+ const std::string& jailId,
+ std::unique_ptr<StorageBase> storage) :
_uriPublic(uriPublic),
_uriJailed(uriJailed),
- _jailId(jailId)
+ _jailId(jailId),
+ _storage(std::move(storage))
{
Log::info("DocumentStoreManager [" + _uriPublic.toString() + "] created.");
}
@@ -141,6 +149,8 @@ private:
const Poco::URI _uriPublic;
const Poco::URI _uriJailed;
const std::string _jailId;
+
+ std::unique_ptr<StorageBase> _storage;
};
#endif
diff --git a/loolwsd/Storage.hpp b/loolwsd/Storage.hpp
index 4e1133b..18a336a 100644
--- a/loolwsd/Storage.hpp
+++ b/loolwsd/Storage.hpp
@@ -56,10 +56,10 @@ public:
/// Returns a local file path given a URI or ID.
/// If necessary copies the file locally first.
- virtual std::string getLocalFilePathFromStorage() = 0;
+ virtual std::string loadStorageFileToLocal() = 0;
/// Writes the contents of the file back to the source.
- virtual bool restoreLocalFileToStorage() = 0;
+ virtual bool saveLocalFileToStorage() = 0;
protected:
const std::string _localStorePath;
@@ -80,7 +80,7 @@ public:
{
}
- std::string getLocalFilePathFromStorage() override
+ std::string loadStorageFileToLocal() override
{
const auto rootPath = getLocalRootPath();
@@ -119,7 +119,7 @@ public:
return Poco::Path(_jailPath, filename).toString();
}
- bool restoreLocalFileToStorage() override
+ bool saveLocalFileToStorage() override
{
try
{
@@ -155,7 +155,7 @@ public:
}
/// uri format: http://server/<...>/wopi*/files/<id>/content
- std::string getLocalFilePathFromStorage() override
+ std::string loadStorageFileToLocal() override
{
Log::info("Downloading URI [" + _uri + "].");
@@ -192,7 +192,7 @@ public:
return Poco::Path(_jailPath, filename).toString();
}
- bool restoreLocalFileToStorage() override
+ bool saveLocalFileToStorage() override
{
Poco::URI uriObject(_uri);
Poco::Net::HTTPClientSession session(uriObject.getHost(), uriObject.getPort());
@@ -221,13 +221,13 @@ public:
{
}
- std::string getLocalFilePathFromStorage() override
+ std::string loadStorageFileToLocal() override
{
// TODO: implement webdav GET.
return _uri;
}
- bool restoreLocalFileToStorage() override
+ bool saveLocalFileToStorage() override
{
// TODO: implement webdav PUT.
return false;
More information about the Libreoffice-commits
mailing list