00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef __STRONGROOMCORE_H_
00014 #define __STRONGROOMCORE_H_
00015
00016 #include <inttypes.h>
00017 #include <string>
00018
00019 #include <Document.h>
00020 #include <Error.h>
00021 #include <FilePlugin.h>
00022 #include <MetadataPlugin.h>
00023 #include <SecurityPlugin.h>
00024 #include <UserPlugin.h>
00025 #include <LogPlugin.h>
00026 #include <fstream>
00027
00028
00029 using namespace std;
00030
00031 enum CoreStatus
00032 {
00033 CORE_INIT_ERROR,
00034 CORE_READY,
00035 CORE_RUNNING,
00036 CORE_SHUTTING_DOWN,
00037 CORE_BROKEN,
00038 CORE_HALTED
00039 };
00040
00041
00057 class StrongroomCore
00058 {
00059 public:
00060
00065 StrongroomCore(string coreConfFile);
00066
00070 ~StrongroomCore();
00071
00077 CoreError coreStart();
00078
00084 CoreError systemShutdown( const UserProfile &admin );
00085
00089 void log( const string &message, int level=0 );
00090
00098 CoreError createDocument( const UserProfile &user, const Document &document, NumID &docid );
00099
00106 CoreError deleteDocument( const UserProfile &user, NumID docid );
00107
00117 CoreError changeDocument( const UserProfile &user, NumID docid, NumID fileid,
00118 string mimetype, NumID &revid );
00119
00127 CoreError deleteRevision( const UserProfile &user, NumID docid, NumID revid );
00128
00138 CoreError addRendition( const UserProfile &user, NumID docid, NumID revid,
00139 NumID fileid, string mimetype );
00140
00148 CoreError getDocumentInfo( const UserProfile &user, NumID docid, Document &document );
00149
00157 CoreError changeDocumentInfo( const UserProfile &user, NumID docid, const Document &document );
00158
00169 CoreError getDocument( const UserProfile &user, NumID docid, NumID revid,
00170 string mimetype, NumID &fileid, int64_t &length );
00171
00180 CoreError queryUpdates( const UserProfile &user, NumID first,
00181 int maxlen, map<NumID,NumID> &updates );
00182
00189 CoreError getLoginChallenge( string username, string &challenge );
00190
00199 CoreError loginUser( string username, string challenge, string response, UserProfile &user );
00200
00210 CoreError addUser( const UserProfile &admin, const UserProfile &userProfile,
00211 string challenge, string password, NumID &userid );
00212
00219 CoreError deleteUser( const UserProfile &admin, NumID userid );
00220
00228 CoreError getUserProfile( const UserProfile &admin, NumID userid, UserProfile &userProfile );
00229
00237 CoreError changeUserProfile( const UserProfile &admin, NumID userid, const UserProfile &userProfile );
00238
00247 CoreError setPassword( const UserProfile &user, string challenge, string oldPassword, string newPassword );
00248
00255 CoreError clearPassword( const UserProfile &admin, NumID userid );
00256
00263 CoreError listUsers( const UserProfile &admin, vector<NumID> &users );
00264
00273 CoreError createNewFile( const UserProfile &user, NumID docid, NumID revid, NumID &fileid );
00274
00280 CoreError deleteNewFile( NumID fileid );
00281
00289 int readFromFile( NumID fileid, uint8_t *buffer, int maxlen );
00290
00298 int writeToFile( NumID fileid, const uint8_t *buffer, int length );
00299
00305 CoreError closeFile( NumID fileid );
00306
00311 CoreStatus coreStatus();
00312
00313 private:
00314 FilePlugin * fileModule;
00315 MetadataPlugin * metadataModule;
00316 SecurityPlugin * securityModule;
00317 UserPlugin * userModule;
00318 LogPlugin * logModule;
00319
00320 CoreStatus status;
00321 };
00322
00323
00341 Plugin *loadModule( string configname, string libname, StrongroomCore *core );
00342
00343 #endif