1 |
douglas |
688 |
// Blog |
2 |
|
|
// |
3 |
|
|
// Douglas Thrift |
4 |
|
|
// |
5 |
|
|
// $Id$ |
6 |
|
|
|
7 |
|
|
#include <cxx/standard.hh> |
8 |
|
|
|
9 |
douglas |
716 |
#include <dbi/connection.hpp> |
10 |
|
|
#include <dbi/driver.hpp> |
11 |
douglas |
717 |
#include <dbi/resultset.hpp> |
12 |
douglas |
716 |
|
13 |
douglas |
688 |
#include "Blog.hpp" |
14 |
|
|
|
15 |
douglas |
713 |
Blog::Blog(const cse::String &sitemap, const cse::String &base, ext::Queue<Url> &queue, api::ThreadMutex &queueLock, const _R<BlogCommand> &command) : CommandRunner(sitemap, queue, queueLock) |
16 |
douglas |
688 |
{ |
17 |
|
|
api::Cout << _B("Blog") << ios::NewLine; |
18 |
douglas |
716 |
|
19 |
|
|
Entries(command->root, _S<ios::String>() << base << command->path); |
20 |
douglas |
688 |
} |
21 |
douglas |
716 |
|
22 |
|
|
void Blog::Entries(const api::Path &directory, const cse::String &base) |
23 |
|
|
{ |
24 |
douglas |
717 |
{ |
25 |
|
|
cse::String blog(client.GetProperty(_B("GoogleTron:Blog"), directory.GetPath())); |
26 |
|
|
|
27 |
|
|
if (blog != _B("MovableType")) |
28 |
|
|
throw ext::NotImplementedException(_S<ios::String>(_B("unknown blog ")) << blog); |
29 |
|
|
} |
30 |
|
|
|
31 |
douglas |
716 |
_R<dbi::Driver> driver(dbi::GetDriver(client.GetProperty(_B("GoogleTron:Driver"), directory.GetPath()))); |
32 |
|
|
_R<dbi::Connection> connection(driver->Connect(client.GetProperty(_B("GoogleTron:Host"), directory.GetPath()), client.GetProperty(_B("GoogleTron:User"), directory.GetPath()), GetPassword(directory), client.GetProperty(_B("GoogleTron:Database"), directory.GetPath()))); |
33 |
douglas |
717 |
int32_t id; |
34 |
|
|
|
35 |
|
|
{ |
36 |
|
|
_R<dbi::ResultSet> set(connection->Parse(_B("SELECT blog_id FROM mt_blog WHERE blog_site_url = ?"))->Execute(base)); |
37 |
|
|
|
38 |
|
|
if (set->MoveNext()) |
39 |
|
|
id = set->Get<int32_t>(0); |
40 |
|
|
else |
41 |
|
|
throw ext::StringException(_S<ios::String>("no blog ") << base); |
42 |
|
|
} |
43 |
douglas |
716 |
} |