refs #597, adjusted update info/global setup

* some renaming
* adjusted to new server paths without dev/productive
* changed to different keys to obtain 2 JSON files in cache
This commit is contained in:
Klaus Basan
2016-02-20 00:16:14 +01:00
committed by Mathew Sutcliffe
parent 92a36890eb
commit b78d8a5088
3 changed files with 43 additions and 23 deletions

View File

@@ -23,8 +23,6 @@ namespace BlackCore
{ {
CGlobalSetup::CGlobalSetup() : CGlobalSetup::CGlobalSetup() :
ITimestampBased(0), ITimestampBased(0),
m_dbHttpPort(80),
m_dbHttpsPort(443),
m_development(CProject::isRunningInDeveloperEnvironment()), m_development(CProject::isRunningInDeveloperEnvironment()),
m_dbRootDirectoryUrl("http://ubuntu12/swiftdatastore/public"), m_dbRootDirectoryUrl("http://ubuntu12/swiftdatastore/public"),
m_vatsimBookingsUrl("http://vatbook.euroutepro.com/xml2.php"), m_vatsimBookingsUrl("http://vatbook.euroutepro.com/xml2.php"),
@@ -80,28 +78,46 @@ namespace BlackCore
return this->m_vatsimMetarsUrl.withAppendedQuery("id=all"); return this->m_vatsimMetarsUrl.withAppendedQuery("id=all");
} }
CUrlList CGlobalSetup::bootstrapUrls() const CUrlList CGlobalSetup::bootstrapFileUrls() const
{ {
CUrlList urls(m_sharedUrls); CUrlList urls(m_sharedUrls);
return urls.appendPath(isDevelopment() ? return urls.appendPath(CGlobalSetup::versionString() + "/bootstrap/bootstrap.json");
CGlobalSetup::versionString() + "/development/bootstrap/bootstrap.json" :
CGlobalSetup::versionString() + "/productive/bootstrap/bootstrap.json");
} }
CUrlList CGlobalSetup::updateInfoUrls() const QString CGlobalSetup::buildBootstrapFileUrl(const QString &candidate)
{ {
CUrlList urls(m_sharedUrls); static const QString vS(QString(versionString()).append("/"));
return urls.appendPath(isDevelopment() ? if (candidate.endsWith("bootstrap.json")) { return candidate; }
CGlobalSetup::versionString() + "/development/updateinfo/updateinfo.json" : CUrl url(candidate);
CGlobalSetup::versionString() + "/productive/updateinfo/updateinfo.json"); if (candidate.contains("/bootstrap"))
{
url.appendPath("bootstrap.json");
}
else if (candidate.endsWith(versionString()) || candidate.endsWith(vS))
{
url.appendPath("/bootstrap/bootstrap.json");
}
else if (candidate.endsWith("shared") || candidate.endsWith("shared/"))
{
url.appendPath(CGlobalSetup::versionString() + "/bootstrap/bootstrap.json");
}
else
{
url.appendPath("shared/" + CGlobalSetup::versionString() + "/bootstrap/bootstrap.json");
}
return url.getFullUrl();
}
CUrlList CGlobalSetup::updateInfoFileUrls() const
{
const CUrlList urls(m_sharedUrls);
return urls.appendPath(CGlobalSetup::versionString() + "/development/updateinfo/updateinfo.json");
} }
CUrlList CGlobalSetup::swiftDbDataFileLocationUrls() const CUrlList CGlobalSetup::swiftDbDataFileLocationUrls() const
{ {
CUrlList urls(m_sharedUrls); const CUrlList urls(m_sharedUrls);
return urls.appendPath(isDevelopment() ? return urls.appendPath(CGlobalSetup::versionString() + "/dbdata/");
CGlobalSetup::versionString() + "/development/dbdata/" :
CGlobalSetup::versionString() + "/productive/dbdata/");
} }
CServerList CGlobalSetup::fsdTestServersPlusHardcodedServers() const CServerList CGlobalSetup::fsdTestServersPlusHardcodedServers() const
@@ -132,10 +148,10 @@ namespace BlackCore
s.append(separator); s.append(separator);
s.append("Update info URLs: "); s.append("Update info URLs: ");
s.append(updateInfoUrls().toQString(i18n)); s.append(updateInfoFileUrls().toQString(i18n));
s.append(separator); s.append(separator);
s.append("Bootstrap URLs: "); s.append("Bootstrap URLs: ");
s.append(bootstrapUrls().toQString(i18n)); s.append(bootstrapFileUrls().toQString(i18n));
s.append(separator); s.append(separator);
s.append("News URLs: "); s.append("News URLs: ");
s.append(swiftLatestNewsUrls().toQString(i18n)); s.append(swiftLatestNewsUrls().toQString(i18n));
@@ -198,9 +214,9 @@ namespace BlackCore
case IndexVatsimMetars: case IndexVatsimMetars:
return CVariant::fromValue(this->m_vatsimMetarsUrl); return CVariant::fromValue(this->m_vatsimMetarsUrl);
case IndexUpdateInfo: case IndexUpdateInfo:
return CVariant::fromValue(this->updateInfoUrls()); return CVariant::fromValue(this->updateInfoFileUrls());
case IndexBootstrap: case IndexBootstrap:
return CVariant::fromValue(this->bootstrapUrls()); return CVariant::fromValue(this->bootstrapFileUrls());
case IndexSwiftDbFiles: case IndexSwiftDbFiles:
return CVariant::fromValue(this->swiftDbDataFileLocationUrls()); return CVariant::fromValue(this->swiftDbDataFileLocationUrls());
case IndexShared: case IndexShared:
@@ -261,5 +277,6 @@ namespace BlackCore
static const QString v("0.6.1"); static const QString v("0.6.1");
return v; return v;
} }
} // ns } // ns
} // ns } // ns

View File

@@ -99,10 +99,10 @@ namespace BlackCore
const BlackMisc::Network::CUrlList &vatsimDataFileUrls() const { return m_vatsimDataFileUrls; } const BlackMisc::Network::CUrlList &vatsimDataFileUrls() const { return m_vatsimDataFileUrls; }
//! Bootstrap URLs (where the data for the setup itself can be downloaded) //! Bootstrap URLs (where the data for the setup itself can be downloaded)
BlackMisc::Network::CUrlList bootstrapUrls() const; BlackMisc::Network::CUrlList bootstrapFileUrls() const;
//! Version and download locations //! Version and download locations
BlackMisc::Network::CUrlList updateInfoUrls() const; BlackMisc::Network::CUrlList updateInfoFileUrls() const;
//! Alternative locations of swift DB data files //! Alternative locations of swift DB data files
BlackMisc::Network::CUrlList swiftDbDataFileLocationUrls() const; BlackMisc::Network::CUrlList swiftDbDataFileLocationUrls() const;
@@ -137,6 +137,9 @@ namespace BlackCore
//! Schema version //! Schema version
static const QString &versionString(); static const QString &versionString();
//! Build bootstrap file URL
static QString buildBootstrapFileUrl(const QString &candidate);
private: private:
BLACK_ENABLE_TUPLE_CONVERSION(BlackCore::Data::CGlobalSetup) BLACK_ENABLE_TUPLE_CONVERSION(BlackCore::Data::CGlobalSetup)
@@ -160,7 +163,7 @@ namespace BlackCore
struct GlobalSetup : public BlackMisc::CDataTrait<CGlobalSetup> struct GlobalSetup : public BlackMisc::CDataTrait<CGlobalSetup>
{ {
//! Key in data cache //! Key in data cache
static const char *key() { return "readers/setup"; } static const char *key() { return "bootstrap"; }
//! Default value //! Default value
static const CGlobalSetup &defaultValue() static const CGlobalSetup &defaultValue()

View File

@@ -106,7 +106,7 @@ namespace BlackCore
struct UpdateInfo : public BlackMisc::CDataTrait<CUpdateInfo> struct UpdateInfo : public BlackMisc::CDataTrait<CUpdateInfo>
{ {
//! Key in data cache //! Key in data cache
static const char *key() { return "readers/updateinfo"; } static const char *key() { return "version"; }
//! Default value //! Default value
static const CUpdateInfo &defaultValue() static const CUpdateInfo &defaultValue()