Go to the documentation of this file.
49 const std::string S_ToolName =
"updatesample";
50 const std::string S_ToolVersion =
"1.2";
57 "<dca-redist-folder> <ticket> <product>\n"
58 " dca-redist-folder - the folder where the DCA is installed to\n"
59 " ticket - a valid ticket\n"
60 " product - the product associated with your ticket\n\n"
68 # define DCA_BINDIR "bin/Win32"
70 # define DCA_BINDIR "bin/linux"
77 #define DCA_INITDIR "init"
83 #define DCA_LOGDIR "./logs"
110 static void SetupLicense(
const std::string& ticket,
const std::string& product,
113 licenseData.
ticket = ticket;
125 struct tm *expirationTime = localtime( &expirationDate );
127 std::cout <<
"License Info:" << std::endl;
128 std::cout <<
" DCA is " << ( aLicense.
isLicensed() ?
"licensed." :
129 "not licensed." ) << std::endl;
130 std::cout <<
" MaxUsers:" << aLicense.
getMaxUsers() <<
134 std::cout <<
" Ticket:" << aLicense.
getTicket() <<
136 std::cout <<
" Session:" << aLicense.
getSession() <<
140 std::cout <<
" Expiration Date:" << asctime( expirationTime ) <<
159 std::cout <<
"Starting update routine..." << std::endl;
163 std::cout <<
"Start update process, paramater force is set to 'false'..." << std::endl;
168 std::cerr <<
"Got error from update. Details: '" << myFR.
getDescription()
169 <<
"' (" << myFR.
getReturnCode() <<
"). Aborting." << std::endl;
173 std::cout <<
"UpdateResults: size=" << results.
size() <<
", restartRequired="
177 if( !results.
size() ) {
178 std::cout <<
"Currently there are no updates available" << std::endl;
188 std::cout <<
"Result #" << i <<
" id=" << result.
id() <<
", contentUpdated="
189 << ( result.
contentUpdated() ?
"true" :
"false" ) <<
", engineUpdated="
190 << ( result.
engineUpdated() ?
"true" :
"false" ) << std::endl;
197 std::string returnMsg =
"internal error";
199 returnMsg =
"download scheduled";
202 returnMsg =
"success";
205 std::cout <<
" Detail #" << j <<
":"
209 <<
"\n available=" << ( detail.
available() ?
"true" :
"false" )
210 <<
"\n downloaded=" << ( detail.
downloaded() ?
"true" :
"false" )
211 <<
"\n installed=" << ( detail.
installed() ?
"true" :
"false" )
212 <<
"\n return=" << returnMsg << std::endl;
216 std::cout <<
"Leaving update routine. All done" << std::endl;
226 std::cout <<
"IBM DCA Sample: " << S_ToolName <<
" (" <<
227 S_ToolVersion <<
")" << std::endl;
237 std::cout << name << std::endl <<
"Usage:" << std::endl;
252 int main(
int argc,
char *argv[] )
265 std::string redist_folder = argv[1];
266 const std::string ticket = argv[2];
267 const std::string product = argv[3];
269 if( redist_folder.empty() || ticket.empty() ||
276 const char c = redist_folder[ redist_folder.length() - 1 ];
277 if( c !=
'/' && c !=
'\\' )
278 redist_folder +=
"/";
313 catch(
const ExDca& ex ) {
314 std::cerr <<
"DCA Exception occured. Details: " << ex.
getDescription() <<
318 catch(
const std::exception& s ) {
319 std::cerr <<
"std::exception occured. Details: " << s.what() <<
"." << std::endl;
323 std::cerr <<
"Unknown exception caught." << std::endl;
Is used to create a License object. A license first must be created with DcaInstance::createLicense t...
Exception class used in the DCA.
std::string oldVersion() const
Returns the version active (installed) before the update was invoked.
void InitCUrl()
Initializes libcurl. Do not use any DCA function before initializing libcurl.
std::string initDir
the directory in which the DCA init files are stored
static UpdateModule create(const DcaInstance &aDcaInstance, const License &aLicense, const ProxySettings &proxySettings=ProxySettings())
int getMaxSessions() const
Returns the maximum allowed sessions associated with your ticket/license.
const std::string S_UsageString
Usage string - that is printed out if a parameter was missing.
time_t getExpirationDate() const
Returns the expiration date of the license in UTC.
std::string getDescription() const
Returns a description of the error.
#define DCA_LOGDIR
Relative directory for logfile(s).
bool downloaded() const
true if an update sucessfully downloaded for this component, false otherwise
int returnCode() const
The internal code of the update, this can be any internal error code, 0 in case of success or DCA_UPD...
Encapsulates the details of a result of an update process.
DCA_RESULT_TYPE getReturnCode() const
Returns the last error code (if any).
bool restartRequired() const
true if an update has been installed that requires a restart of the DCA, false otherwise.
The update module is used to download and install DCA content and engine updates.
bool installed() const
true if an update sucessfully installed for this component, false otherwise
std::string binDir
the directory in which the DCA binary (*.dca) files are stored
This header includes initialization/deinitialization support functions for the 3rd party libraries us...
Encapsulates the results of an update process.
static void PrintLicenseInfo(const License &aLicense)
Prints out the information about the provided License.
void SetOpenSslCallbacks()
Initializes the required callbacks for OpenSSL when using HTTPS or SSL connections in a multi-threade...
void UnsetOpenSslCallbacks()
Unsets the openssl callbacks. Do not call any DCA function after you have called this function.
const int DCA_UPDATE_DOWNLOAD_SCHEDULED
Internal DCA status code to indicate that a potentially time consuming download has been scheduled....
int getMaxUsers() const
Returns the maximum allowed users associated with your ticket/license.
void DeinitCUrl()
Deinitializes libcurl. Do not call any DCA function after you have called this function.
static void SetupLicense(const std::string &ticket, const std::string &product, LicenseData &licenseData)
Sets up the given licenseData by copying the given ticket and product strings.
bool contentUpdated() const
If true the update(s) include a content update.
DCA_RESULT_TYPE getReturnCode() const
Gets the code of the error.
std::string newVersion() const
Returns the version currently active (installed).
bool available() const
true if an update was available for this component, false otherwise
Encapsulates one of the results of an update process.
Use a License to initialize a classification package or a toolbox package.
FunctionResult performUpdate(bool force, UpdateResults &results) const
Performs an update for all licensed and initialized DCA modules and classifiers.
bool isLicensed(DCA_MODULE_ID_TYPE id=0, bool force=false) const
Checks whether the given License is valid for the given module id.
std::string ticket
The ticket as provided in the license.
This header includes all header files of the DCA Base Package.
static void PrintUsage(const char *name)
Prints out the syntax of the sample.
Encapsulates the init and deinit of the DCA API.
std::string product
The product code used with the license.
static DCA_MODULE_ID_TYPE ID
This is the module id of the update module.
static void SetupInitData(const std::string &redist_folder, InitData &initData)
Sets up the given initData by substituting the given redist_folder with DCA subdirectories.
std::string logDir
the directory in which the DCA log file should be created
std::string getLastMessage() const
Returns the last message received from our license server or if none available the last available mes...
size_t DCA_INDEX_TYPE
Type for index access (used for arrays and collections).
#define DCA_BINDIR
DCA subdirectory of the DCA binaries.
DCA_SIZE_TYPE size() const
Returns the number of available details (if any).
std::string getDescription() const
Returns the description for the error or warning.
static void PrintToolHeader()
Prints out the name and the version of this sample.
size_t DCA_SIZE_TYPE
Type for size (used for size of array and collections).
bool engineUpdated() const
If true the update(s) include an engine update.
std::string getTicket() const
Returns the ticket of the license as string.
Standard function result.
std::string getSession() const
Returns the session of the license as string.
#define DCA_INITDIR
DCA subdirectory of the DCA initialization data.
int TestUpdate(const DcaInstance &myDca, const License &myLicense)
Sets up required classes and performs an update by calling UpdateModule::performUpdate().
This structure is used to initialize the DcaInstance.
static DcaInstance create(const InitData &initData)
Creates a DcaInstance, starts up the DCA API and initializes the required main module.
DCA_SIZE_TYPE size() const
Returns the number of results available .
License createLicense(const LicenseData &licData, const ProxySettings &proxySettings=ProxySettings(), LogLevel aLogLevel=LOG_Initial) const
Creates a License object using the given LicenseData.
DCA_MODULE_ID_TYPE id() const
Returns the module ID for which the updates have been installed.
int main(int argc, char *argv[])
The main routine.
std::string component() const
Returns the name of the component the detail applies to.