blob: 0a3880dccecb84d12199157099ac106a7873411f [file] [log] [blame]
Alexander Afanasyev5e9e46e2013-01-02 14:12:50 -08001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2013 University of California, Los Angeles
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19 * Zhenkai Zhu <zhenkai@cs.ucla.edu>
20 */
21
22#include "notify-i.h"
Alexander Afanasyeva199f972013-01-02 19:37:26 -080023#include <hash-helper.h>
Alexander Afanasyev5e9e46e2013-01-02 14:12:50 -080024
25using namespace std;
Alexander Afanasyevb6bc01a2013-01-02 23:34:20 -080026using namespace boost;
Alexander Afanasyev5e9e46e2013-01-02 14:12:50 -080027
Alexander Afanasyevb6bc01a2013-01-02 23:34:20 -080028NotifyI::NotifyI (ActionLogPtr &actionLog)
29 : m_actionLog (actionLog)
30{
31}
Alexander Afanasyeva199f972013-01-02 19:37:26 -080032
Alexander Afanasyev5e9e46e2013-01-02 14:12:50 -080033void
34NotifyI::updateFile (const ::std::string &filename,
Alexander Afanasyeva199f972013-01-02 19:37:26 -080035 const ::std::pair<const Ice::Byte*, const Ice::Byte*> &hashRaw,
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080036 ::Ice::Long wtime,
Alexander Afanasyev5e9e46e2013-01-02 14:12:50 -080037 ::Ice::Int mode,
38 const ::Ice::Current&)
39{
Alexander Afanasyeva199f972013-01-02 19:37:26 -080040 Hash hash (hashRaw.first, hashRaw.second-hashRaw.first);
41
Alexander Afanasyevb6bc01a2013-01-02 23:34:20 -080042 cout << "updateFile " << filename << " with hash " << hash << endl;
43 try
44 {
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080045 m_actionLog->AddActionUpdate (filename, hash, wtime, mode);
Alexander Afanasyevb6bc01a2013-01-02 23:34:20 -080046
47 m_actionLog->RememberStateInStateLog ();
48 }
49 catch (const boost::exception &e)
50 {
51 cout << "ERRORR: " << *get_error_info<errmsg_info_str> (e) << endl;
52 }
Alexander Afanasyev5e9e46e2013-01-02 14:12:50 -080053}
54
Alexander Afanasyeva199f972013-01-02 19:37:26 -080055void
56NotifyI::moveFile (const ::std::string &oldFilename,
57 const ::std::string &newFilename,
58 const ::Ice::Current&)
59{
Alexander Afanasyevb6bc01a2013-01-02 23:34:20 -080060 cout << "moveFile from " << oldFilename << " to " << newFilename << endl;
61 // m_actionLog->AddActionMove (oldFilename, newFilename);
Alexander Afanasyeva199f972013-01-02 19:37:26 -080062}
Alexander Afanasyev5e9e46e2013-01-02 14:12:50 -080063
64void
65NotifyI::deleteFile (const ::std::string &filename,
66 const ::Ice::Current&)
67{
Alexander Afanasyevb6bc01a2013-01-02 23:34:20 -080068 cout << "deleteFile " << filename << endl;
69 m_actionLog->AddActionDelete (filename);
70 m_actionLog->RememberStateInStateLog ();
Alexander Afanasyev5e9e46e2013-01-02 14:12:50 -080071}
72