CreateBackupCloseMethod.cxx

Go to the documentation of this file.
00001 /*------------------------------------------------------------------------------
00002  
00003     Copyright (c) 2004 Media Development Loan Fund
00004   
00005     This file is part of the Campcaster project.
00006     https://www.campware.org/
00007     To report bugs, send an e-mail to [email protected]
00008   
00009     Campcaster is free software; you can redistribute it and/or modify
00010     it under the terms of the GNU General Public License as published by
00011     the Free Software Foundation; either version 2 of the License, or
00012     (at your option) any later version.
00013    
00014     Campcaster is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017     GNU General Public License for more details.
00018   
00019     You should have received a copy of the GNU General Public License
00020     along with Campcaster; if not, write to the Free Software
00021     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022   
00023   
00024     Author   : $Author: fgerlits $
00025     Version  : $Revision: 2329 $
00026     Location : $URL: svn://code.campware.org/campcaster/trunk/campcaster/src/products/scheduler/src/CreateBackupCloseMethod.cxx $
00027  
00028 ------------------------------------------------------------------------------*/
00029 
00030 /* ============================================================ include files */
00031 
00032 #ifdef HAVE_CONFIG_H
00033  #include "configure.h"
00034 #endif
00035  
00036 #ifdef HAVE_TIME_H
00037  #include <time.h>
00038 #else
00039  #error need time.h
00040  #endif
00041  
00042 
00043 #include <string>
00044 
00045 #include "LiveSupport/Core/XmlRpcTools.h"
00046 #include "LiveSupport/Core/XmlRpcException.h"
00047 #include "BackupFactory.h"
00048 
00049 #include "CreateBackupCloseMethod.h"
00050 
00051 
00052 using namespace LiveSupport;
00053 using namespace LiveSupport::Core;
00054 
00055 using namespace LiveSupport::Scheduler;
00056 
00057 /* ===================================================  local data structures */
00058 
00059 
00060 /* ================================================  local constants & macros */
00061 
00062 /*------------------------------------------------------------------------------
00063  *  The name of this XML-RPC method.
00064  *----------------------------------------------------------------------------*/
00065 const std::string   CreateBackupCloseMethod::methodName = "createBackupClose";
00066 
00067 /*------------------------------------------------------------------------------
00068  *  The ID of this method for error reporting purposes.
00069  *----------------------------------------------------------------------------*/
00070 const int           CreateBackupCloseMethod::errorId = 4200;
00071 
00072 
00073 /* ===============================================  local function prototypes */
00074 
00075 
00076 /* =============================================================  module code */
00077 
00078 /*------------------------------------------------------------------------------
00079  *  Construct the method and register it right away.
00080  *----------------------------------------------------------------------------*/
00081 CreateBackupCloseMethod :: CreateBackupCloseMethod(
00082                                 Ptr<XmlRpc::XmlRpcServer>::Ref  xmlRpcServer)
00083                                                                     throw()
00084     : XmlRpc::XmlRpcServerMethod(methodName, xmlRpcServer.get())
00085 {
00086 }
00087 
00088 
00089 /*------------------------------------------------------------------------------
00090  *  Execute the upload playlist method XML-RPC function call.
00091  *----------------------------------------------------------------------------*/
00092 void
00093 CreateBackupCloseMethod :: execute(XmlRpc::XmlRpcValue &     rootParameter,
00094                                   XmlRpc::XmlRpcValue &     returnValue)
00095                                                 throw (XmlRpc::XmlRpcException)
00096 {
00097     if (!rootParameter.valid() || rootParameter.size() != 1
00098                                || !rootParameter[0].valid()) {
00099         XmlRpcTools::markError(errorId+1, "invalid argument format", 
00100                                returnValue);
00101         return;
00102     }
00103     XmlRpc::XmlRpcValue         parameters = rootParameter[0];
00104 
00105     Ptr<Glib::ustring>::Ref     token;
00106     try{
00107         token = XmlRpcTools::extractToken(parameters);
00108         
00109     } catch (std::invalid_argument &e) {
00110         XmlRpcTools::markError(errorId+2, 
00111                                "missing token argument",
00112                                returnValue);
00113         return;
00114     }
00115 
00116     Ptr<BackupFactory>::Ref     bf      = BackupFactory::getInstance();
00117     Ptr<BackupInterface>::Ref   backup  = bf->getBackup();
00118     
00119     try {
00120         backup->createBackupClose(*token);
00121         
00122     } catch (Core::XmlRpcException &e) {
00123         XmlRpcTools::markError(errorId+10, e.what(), returnValue);
00124         return;
00125     }
00126 }
00127 

Generated on Sat Sep 22 02:00:23 2007 for Campcaster by  1.4.7