RdbmsCatalogue.cpp 356 KB
Newer Older
1
/*
2
 * @project        The CERN Tape Archive (CTA)
3
 * @copyright      Copyright(C) 2015-2021 CERN
4
5
6
7
 * @license        This program is free software: you can redistribute it and/or modify
 *                 it under the terms of the GNU General Public License as published by
 *                 the Free Software Foundation, either version 3 of the License, or
 *                 (at your option) any later version.
8
 *
9
10
11
12
 *                 This program is distributed in the hope that it will be useful,
 *                 but WITHOUT ANY WARRANTY; without even the implied warranty of
 *                 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *                 GNU General Public License for more details.
13
 *
14
15
 *                 You should have received a copy of the GNU General Public License
 *                 along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17
 */

18
#include "catalogue/ArchiveFileRow.hpp"
19
#include "catalogue/ArchiveFileRowWithoutTimestamps.hpp"
20
#include "catalogue/RdbmsCatalogue.hpp"
21
#include "catalogue/RdbmsCatalogueGetArchiveFilesItor.hpp"
22
#include "catalogue/RdbmsCatalogueGetArchiveFilesForRepackItor.hpp"
23
#include "catalogue/RdbmsCatalogueTapeContentsItor.hpp"
24
#include "catalogue/SchemaVersion.hpp"
25
#include "catalogue/SqliteCatalogueSchema.hpp"
26
#include "common/dataStructures/TapeFile.hpp"
27
#include "common/exception/Exception.hpp"
28
#include "common/exception/LostDatabaseConnection.hpp"
29
#include "common/exception/UserError.hpp"
30
31
#include "common/log/DummyLogger.hpp"
#include "common/log/TimingList.hpp"
32
#include "common/make_unique.hpp"
33
#include "common/threading/MutexLocker.hpp"
34
#include "common/Timer.hpp"
35
#include "common/utils/utils.hpp"
36
#include "rdbms/AutoRollback.hpp"
37
#include "version.h"
38
#include "RdbmsCatalogueGetFileRecycleLogItor.hpp"
39

40
#include <ctype.h>
41
42
#include <memory>
#include <time.h>
43
44
#include <sys/types.h>
#include <grp.h>
45

46
47
48
namespace cta {
namespace catalogue {

49
50
51
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
52
RdbmsCatalogue::RdbmsCatalogue(
53
  log::Logger &log,
54
  const rdbms::Login &login,
55
  const uint64_t nbConns,
56
  const uint64_t nbArchiveFileListingConns):
57
  m_log(log),
58
  m_connPool(login, nbConns),
59
  m_archiveFileListingConnPool(login, nbArchiveFileListingConns),
Steven Murray's avatar
Steven Murray committed
60
61
62
  m_tapeCopyToPoolCache(10),
  m_groupMountPolicyCache(10),
  m_userMountPolicyCache(10),
63
  m_allMountPoliciesCache(60),
64
  m_tapepoolVirtualOrganizationCache(60),
65
  m_expectedNbArchiveRoutesCache(10),
66
67
  m_isAdminCache(10),
  m_activitiesFairShareWeights(10) {}
68
69
70
71

//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
72
RdbmsCatalogue::~RdbmsCatalogue() {
73
74
75
76
77
}

//------------------------------------------------------------------------------
// createAdminUser
//------------------------------------------------------------------------------
78
void RdbmsCatalogue::createAdminUser(
Steven Murray's avatar
Steven Murray committed
79
  const common::dataStructures::SecurityIdentity &admin,
80
  const std::string &username,
81
  const std::string &comment) {
Steven Murray's avatar
Steven Murray committed
82
  try {
83
84
85
86
87
    if(username.empty()) {
      throw UserSpecifiedAnEmptyStringUsername("Cannot create admin user because the username is an empty string");
    }

    if(comment.empty()) {
88
      throw UserSpecifiedAnEmptyStringComment("Cannot create admin user because the comment is an empty string");
89
90
    }

91
    auto conn = m_connPool.getConn();
92
    if (adminUserExists(conn, username)) {
93
      throw exception::UserError(std::string("Cannot create admin user " + username +
94
95
        " because an admin user with the same name already exists"));
    }
96
    const uint64_t now = time(nullptr);
Steven Murray's avatar
Steven Murray committed
97
98
99
100
101
102
103
104
105
106
107
108
109
    const char *const sql =
      "INSERT INTO ADMIN_USER("
        "ADMIN_USER_NAME,"

        "USER_COMMENT,"

        "CREATION_LOG_USER_NAME,"
        "CREATION_LOG_HOST_NAME,"
        "CREATION_LOG_TIME,"

        "LAST_UPDATE_USER_NAME,"
        "LAST_UPDATE_HOST_NAME,"
        "LAST_UPDATE_TIME)"
110
      "VALUES("
Steven Murray's avatar
Steven Murray committed
111
112
113
114
115
116
117
118
        ":ADMIN_USER_NAME,"

        ":USER_COMMENT,"

        ":CREATION_LOG_USER_NAME,"
        ":CREATION_LOG_HOST_NAME,"
        ":CREATION_LOG_TIME,"

119
120
121
        ":LAST_UPDATE_USER_NAME,"
        ":LAST_UPDATE_HOST_NAME,"
        ":LAST_UPDATE_TIME)";
122
    auto stmt = conn.createStmt(sql);
Steven Murray's avatar
Steven Murray committed
123

124
    stmt.bindString(":ADMIN_USER_NAME", username);
Steven Murray's avatar
Steven Murray committed
125

126
    stmt.bindString(":USER_COMMENT", comment);
Steven Murray's avatar
Steven Murray committed
127

128
129
130
    stmt.bindString(":CREATION_LOG_USER_NAME", admin.username);
    stmt.bindString(":CREATION_LOG_HOST_NAME", admin.host);
    stmt.bindUint64(":CREATION_LOG_TIME", now);
Steven Murray's avatar
Steven Murray committed
131

132
133
134
    stmt.bindString(":LAST_UPDATE_USER_NAME", admin.username);
    stmt.bindString(":LAST_UPDATE_HOST_NAME", admin.host);
    stmt.bindUint64(":LAST_UPDATE_TIME", now);
135

136
    stmt.executeNonQuery();
137
138
139
140
  } catch(exception::UserError &) {
    throw;
  } catch(exception::Exception &ex) {
    ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
141
142
143
144
145
146
147
    throw;
  }
}

//------------------------------------------------------------------------------
// adminUserExists
//------------------------------------------------------------------------------
148
bool RdbmsCatalogue::adminUserExists(rdbms::Conn &conn, const std::string adminUsername) const {
149
150
151
152
153
154
155
  try {
    const char *const sql =
      "SELECT "
        "ADMIN_USER_NAME AS ADMIN_USER_NAME "
      "FROM "
        "ADMIN_USER "
      "WHERE "
156
        "ADMIN_USER_NAME = :ADMIN_USER_NAME";
157
    auto stmt = conn.createStmt(sql);
158
    stmt.bindString(":ADMIN_USER_NAME", adminUsername);
159
    auto rset = stmt.executeQuery();
160
    return rset.next();
161
162
  } catch(exception::UserError &) {
    throw;
163
164
165
  } catch(exception::Exception &ex) {
    ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
    throw;
Steven Murray's avatar
Steven Murray committed
166
  }
167
168
}

169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
//------------------------------------------------------------------------------
// virtualOrganizationExists
//------------------------------------------------------------------------------
bool RdbmsCatalogue::virtualOrganizationExists(rdbms::Conn &conn, const std::string &voName) const {
  try {
    const char *const sql =
      "SELECT "
        "VIRTUAL_ORGANIZATION_NAME AS VIRTUAL_ORGANIZATION_NAME "
      "FROM "
        "VIRTUAL_ORGANIZATION "
      "WHERE "
        "VIRTUAL_ORGANIZATION_NAME = :VIRTUAL_ORGANIZATION_NAME";
    auto stmt = conn.createStmt(sql);
    stmt.bindString(":VIRTUAL_ORGANIZATION_NAME", voName);
    auto rset = stmt.executeQuery();
    return rset.next();
  } catch(exception::UserError &) {
    throw;
  } catch(exception::Exception &ex) {
    ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
    throw;
  }
}

193
194
195
//------------------------------------------------------------------------------
// deleteAdminUser
//------------------------------------------------------------------------------
196
void RdbmsCatalogue::deleteAdminUser(const std::string &username) {
197
  try {
198
    const char *const sql = "DELETE FROM ADMIN_USER WHERE ADMIN_USER_NAME = :ADMIN_USER_NAME";
199
    auto conn = m_connPool.getConn();
200
    auto stmt = conn.createStmt(sql);
201
    stmt.bindString(":ADMIN_USER_NAME", username);
202
    stmt.executeNonQuery();
203

204
    if(0 == stmt.getNbAffectedRows()) {
205
      throw exception::UserError(std::string("Cannot delete admin-user ") + username + " because they do not exist");
206
    }
207
208
209
210
  } catch(exception::UserError &) {
    throw;
  } catch(exception::Exception &ex) {
    ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
211
212
    throw;
  }
Steven Murray's avatar
Steven Murray committed
213
}
214
215
216
217

//------------------------------------------------------------------------------
// getAdminUsers
//------------------------------------------------------------------------------
218
std::list<common::dataStructures::AdminUser> RdbmsCatalogue::getAdminUsers() const {
Steven Murray's avatar
Steven Murray committed
219
220
221
222
223
  try {
    std::list<common::dataStructures::AdminUser> admins;
    const char *const sql =
      "SELECT "
        "ADMIN_USER_NAME AS ADMIN_USER_NAME,"
224

Steven Murray's avatar
Steven Murray committed
225
        "USER_COMMENT AS USER_COMMENT,"
226

227
228
229
        "CREATION_LOG_USER_NAME AS CREATION_LOG_USER_NAME,"
        "CREATION_LOG_HOST_NAME AS CREATION_LOG_HOST_NAME,"
        "CREATION_LOG_TIME AS CREATION_LOG_TIME,"
230

231
232
233
        "LAST_UPDATE_USER_NAME AS LAST_UPDATE_USER_NAME,"
        "LAST_UPDATE_HOST_NAME AS LAST_UPDATE_HOST_NAME,"
        "LAST_UPDATE_TIME AS LAST_UPDATE_TIME "
234
      "FROM "
235
236
237
        "ADMIN_USER "
      "ORDER BY "
        "ADMIN_USER_NAME";
238
    auto conn = m_connPool.getConn();
239
    auto stmt = conn.createStmt(sql);
240
    auto rset = stmt.executeQuery();
241
    while (rset.next()) {
Steven Murray's avatar
Steven Murray committed
242
      common::dataStructures::AdminUser admin;
243

244
245
246
247
248
249
250
251
      admin.name = rset.columnString("ADMIN_USER_NAME");
      admin.comment = rset.columnString("USER_COMMENT");
      admin.creationLog.username = rset.columnString("CREATION_LOG_USER_NAME");
      admin.creationLog.host = rset.columnString("CREATION_LOG_HOST_NAME");
      admin.creationLog.time = rset.columnUint64("CREATION_LOG_TIME");
      admin.lastModificationLog.username = rset.columnString("LAST_UPDATE_USER_NAME");
      admin.lastModificationLog.host = rset.columnString("LAST_UPDATE_HOST_NAME");
      admin.lastModificationLog.time = rset.columnUint64("LAST_UPDATE_TIME");
252

Steven Murray's avatar
Steven Murray committed
253
254
      admins.push_back(admin);
    }
255

Steven Murray's avatar
Steven Murray committed
256
    return admins;
257
258
  } catch(exception::UserError &) {
    throw;
259
260
261
  } catch(exception::Exception &ex) {
    ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
    throw;
Steven Murray's avatar
Steven Murray committed
262
  }
263
264
265
266
267
}

//------------------------------------------------------------------------------
// modifyAdminUserComment
//------------------------------------------------------------------------------
Steven Murray's avatar
Steven Murray committed
268
void RdbmsCatalogue::modifyAdminUserComment(const common::dataStructures::SecurityIdentity &admin,
269
270
  const std::string &username, const std::string &comment) {
  try {
271
272
273
274
275
    if(username.empty()) {
      throw UserSpecifiedAnEmptyStringUsername("Cannot modify admin user because the username is an empty string");
    }

    if(comment.empty()) {
276
      throw UserSpecifiedAnEmptyStringComment("Cannot modify admin user because the comment is an empty string");
277
278
    }

279
280
281
282
283
284
285
    const time_t now = time(nullptr);
    const char *const sql =
      "UPDATE ADMIN_USER SET "
        "USER_COMMENT = :USER_COMMENT,"
        "LAST_UPDATE_USER_NAME = :LAST_UPDATE_USER_NAME,"
        "LAST_UPDATE_HOST_NAME = :LAST_UPDATE_HOST_NAME,"
        "LAST_UPDATE_TIME = :LAST_UPDATE_TIME "
286
      "WHERE "
287
288
        "ADMIN_USER_NAME = :ADMIN_USER_NAME";
    auto conn = m_connPool.getConn();
289
    auto stmt = conn.createStmt(sql);
290
291
292
293
294
    stmt.bindString(":USER_COMMENT", comment);
    stmt.bindString(":LAST_UPDATE_USER_NAME", admin.username);
    stmt.bindString(":LAST_UPDATE_HOST_NAME", admin.host);
    stmt.bindUint64(":LAST_UPDATE_TIME", now);
    stmt.bindString(":ADMIN_USER_NAME", username);
295
    stmt.executeNonQuery();
296
297

    if(0 == stmt.getNbAffectedRows()) {
298
299
300
301
      throw exception::UserError(std::string("Cannot modify admin user ") + username + " because they do not exist");
    }
  } catch(exception::UserError &) {
    throw;
302
303
304
  } catch(exception::Exception &ex) {
    ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
    throw;
305
  }
Steven Murray's avatar
Steven Murray committed
306
}
307
308

//------------------------------------------------------------------------------
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
// createVirtualOrganization
//------------------------------------------------------------------------------
void RdbmsCatalogue::createVirtualOrganization(const common::dataStructures::SecurityIdentity &admin, const common::dataStructures::VirtualOrganization &vo){
  try{
    if(vo.name.empty()){
      throw UserSpecifiedAnEmptyStringVo("Cannot create virtual organization because the name is an empty string");
    }
    if(vo.comment.empty()) {
      throw UserSpecifiedAnEmptyStringComment("Cannot create virtual organization because the comment is an empty string");
    }
    auto conn = m_connPool.getConn();
    if(virtualOrganizationExists(conn, vo.name)) {
      throw exception::UserError(std::string("Cannot create vo : ") +
        vo.name + " because it already exists");
    }
    const uint64_t virtualOrganizationId = getNextVirtualOrganizationId(conn);
    const time_t now = time(nullptr);
    const char *const sql = 
    "INSERT INTO VIRTUAL_ORGANIZATION("
        "VIRTUAL_ORGANIZATION_ID,"
        "VIRTUAL_ORGANIZATION_NAME,"
330
        
331
332
        "READ_MAX_DRIVES,"
        "WRITE_MAX_DRIVES,"
333
334
335
336
337
338
339
340
341
342
343
344
345

        "USER_COMMENT,"

        "CREATION_LOG_USER_NAME,"
        "CREATION_LOG_HOST_NAME,"
        "CREATION_LOG_TIME,"

        "LAST_UPDATE_USER_NAME,"
        "LAST_UPDATE_HOST_NAME,"
        "LAST_UPDATE_TIME)"
      "VALUES("
        ":VIRTUAL_ORGANIZATION_ID,"
        ":VIRTUAL_ORGANIZATION_NAME,"
346
347
        ":READ_MAX_DRIVES,"
        ":WRITE_MAX_DRIVES,"
348
349
350
351
352
353
354
355
356
357
358
359
360
361

        ":USER_COMMENT,"

        ":CREATION_LOG_USER_NAME,"
        ":CREATION_LOG_HOST_NAME,"
        ":CREATION_LOG_TIME,"

        ":LAST_UPDATE_USER_NAME,"
        ":LAST_UPDATE_HOST_NAME,"
        ":LAST_UPDATE_TIME)";
    auto stmt = conn.createStmt(sql);
    
    stmt.bindUint64(":VIRTUAL_ORGANIZATION_ID", virtualOrganizationId);
    stmt.bindString(":VIRTUAL_ORGANIZATION_NAME", vo.name);
362
    
363
364
    stmt.bindUint64(":READ_MAX_DRIVES",vo.readMaxDrives);
    stmt.bindUint64(":WRITE_MAX_DRIVES",vo.writeMaxDrives);
365
366

    stmt.bindString(":USER_COMMENT", vo.comment);
367
    
368
369
370
371
372
373
374
375
376
377
    stmt.bindString(":CREATION_LOG_USER_NAME", admin.username);
    stmt.bindString(":CREATION_LOG_HOST_NAME", admin.host);
    stmt.bindUint64(":CREATION_LOG_TIME", now);

    stmt.bindString(":LAST_UPDATE_USER_NAME", admin.username);
    stmt.bindString(":LAST_UPDATE_HOST_NAME", admin.host);
    stmt.bindUint64(":LAST_UPDATE_TIME", now);

    stmt.executeNonQuery();
    
378
379
    m_tapepoolVirtualOrganizationCache.invalidate();
    
380
381
382
383
384
385
386
387
  } catch(exception::UserError &) {
    throw;
  } catch(exception::Exception &ex) {
    ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
    throw;
  }
}

388
389
390
391
392
393
394
395
//------------------------------------------------------------------------------
// deleteVirtualOrganization
//------------------------------------------------------------------------------
void RdbmsCatalogue::deleteVirtualOrganization(const std::string &voName){
  try {
    auto conn = m_connPool.getConn();

    if(virtualOrganizationIsUsedByStorageClasses(conn, voName)) {
396
397
      throw UserSpecifiedStorageClassUsedByArchiveRoutes(std::string("The Virtual Organization ") + voName +
        " is being used by one or more storage classes");
398
399
400
    }

    if(virtualOrganizationIsUsedByTapepools(conn, voName)) {
401
402
      throw UserSpecifiedStorageClassUsedByArchiveFiles(std::string("The Virtual Organization ") + voName +
        " is being used by one or more Tapepools");
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
    }

    const char *const sql =
      "DELETE FROM "
        "VIRTUAL_ORGANIZATION "
      "WHERE "
        "VIRTUAL_ORGANIZATION_NAME = :VIRTUAL_ORGANIZATION_NAME";
    auto stmt = conn.createStmt(sql);

    stmt.bindString(":VIRTUAL_ORGANIZATION_NAME", voName);

    stmt.executeNonQuery();
    if(0 == stmt.getNbAffectedRows()) {
      throw exception::UserError(std::string("Cannot delete Virtual Organization : ") +
        voName + " because it does not exist");
    }
419
    m_tapepoolVirtualOrganizationCache.invalidate();
420
421
422
423
424
425
426
427
  } catch(exception::UserError &) {
    throw;
  } catch(exception::Exception &ex) {
    ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
    throw;
  }
}

428
429
430
431
432
433
434
435
436
437
//------------------------------------------------------------------------------
// getVirtualOrganizations
//------------------------------------------------------------------------------
std::list<common::dataStructures::VirtualOrganization> RdbmsCatalogue::getVirtualOrganizations() const {
  try {
    std::list<common::dataStructures::VirtualOrganization> virtualOrganizations;
    const char *const sql =
      "SELECT "
        "VIRTUAL_ORGANIZATION_NAME AS VIRTUAL_ORGANIZATION_NAME,"

438
439
        "READ_MAX_DRIVES AS READ_MAX_DRIVES,"
        "WRITE_MAX_DRIVES AS WRITE_MAX_DRIVES,"
440

441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
        "USER_COMMENT AS USER_COMMENT,"

        "CREATION_LOG_USER_NAME AS CREATION_LOG_USER_NAME,"
        "CREATION_LOG_HOST_NAME AS CREATION_LOG_HOST_NAME,"
        "CREATION_LOG_TIME AS CREATION_LOG_TIME,"

        "LAST_UPDATE_USER_NAME AS LAST_UPDATE_USER_NAME,"
        "LAST_UPDATE_HOST_NAME AS LAST_UPDATE_HOST_NAME,"
        "LAST_UPDATE_TIME AS LAST_UPDATE_TIME "
      "FROM "
        "VIRTUAL_ORGANIZATION "
      "ORDER BY "
        "VIRTUAL_ORGANIZATION_NAME";
    auto conn = m_connPool.getConn();
    auto stmt = conn.createStmt(sql);
    auto rset = stmt.executeQuery();
    while (rset.next()) {
      common::dataStructures::VirtualOrganization virtualOrganization;

      virtualOrganization.name = rset.columnString("VIRTUAL_ORGANIZATION_NAME");

462
463
      virtualOrganization.readMaxDrives = rset.columnUint64("READ_MAX_DRIVES");
      virtualOrganization.writeMaxDrives = rset.columnUint64("WRITE_MAX_DRIVES");
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
      virtualOrganization.comment = rset.columnString("USER_COMMENT");
      virtualOrganization.creationLog.username = rset.columnString("CREATION_LOG_USER_NAME");
      virtualOrganization.creationLog.host = rset.columnString("CREATION_LOG_HOST_NAME");
      virtualOrganization.creationLog.time = rset.columnUint64("CREATION_LOG_TIME");
      virtualOrganization.lastModificationLog.username = rset.columnString("LAST_UPDATE_USER_NAME");
      virtualOrganization.lastModificationLog.host = rset.columnString("LAST_UPDATE_HOST_NAME");
      virtualOrganization.lastModificationLog.time = rset.columnUint64("LAST_UPDATE_TIME");

      virtualOrganizations.push_back(virtualOrganization);
    }

    return virtualOrganizations;
  } catch(exception::UserError &) {
    throw;
  } catch(exception::Exception &ex) {
    ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
    throw;
  }
}

484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
//------------------------------------------------------------------------------
// getVirtualOrganizationOfTapepool
//------------------------------------------------------------------------------
common::dataStructures::VirtualOrganization RdbmsCatalogue::getVirtualOrganizationOfTapepool(const std::string & tapepoolName) const {
  try {
    auto conn = m_connPool.getConn();
    return getVirtualOrganizationOfTapepool(conn,tapepoolName);
  } catch(exception::UserError &) {
    throw;
  } catch(exception::Exception &ex) {
    ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
    throw;
  }
}

//------------------------------------------------------------------------------
// getVirtualOrganizationOfTapepool
//------------------------------------------------------------------------------
common::dataStructures::VirtualOrganization RdbmsCatalogue::getVirtualOrganizationOfTapepool(rdbms::Conn & conn, const std::string & tapepoolName) const {
  try {
    const char *const sql =
      "SELECT "
        "VIRTUAL_ORGANIZATION.VIRTUAL_ORGANIZATION_NAME AS VIRTUAL_ORGANIZATION_NAME,"

        "VIRTUAL_ORGANIZATION.READ_MAX_DRIVES AS READ_MAX_DRIVES,"
        "VIRTUAL_ORGANIZATION.WRITE_MAX_DRIVES AS WRITE_MAX_DRIVES,"

        "VIRTUAL_ORGANIZATION.USER_COMMENT AS USER_COMMENT,"

        "VIRTUAL_ORGANIZATION.CREATION_LOG_USER_NAME AS CREATION_LOG_USER_NAME,"
        "VIRTUAL_ORGANIZATION.CREATION_LOG_HOST_NAME AS CREATION_LOG_HOST_NAME,"
        "VIRTUAL_ORGANIZATION.CREATION_LOG_TIME AS CREATION_LOG_TIME,"

        "VIRTUAL_ORGANIZATION.LAST_UPDATE_USER_NAME AS LAST_UPDATE_USER_NAME,"
        "VIRTUAL_ORGANIZATION.LAST_UPDATE_HOST_NAME AS LAST_UPDATE_HOST_NAME,"
        "VIRTUAL_ORGANIZATION.LAST_UPDATE_TIME AS LAST_UPDATE_TIME "
      "FROM "
        "TAPE_POOL "
      "INNER JOIN "
        "VIRTUAL_ORGANIZATION "
      "ON "
        "TAPE_POOL.VIRTUAL_ORGANIZATION_ID = VIRTUAL_ORGANIZATION.VIRTUAL_ORGANIZATION_ID "
      "WHERE "
        "TAPE_POOL.TAPE_POOL_NAME = :TAPE_POOL_NAME";
    auto stmt = conn.createStmt(sql);
    stmt.bindString(":TAPE_POOL_NAME",tapepoolName);
    auto rset = stmt.executeQuery();
    if(!rset.next()){
      throw exception::UserError(std::string("In RdbmsCatalogue::getVirtualOrganizationsOfTapepool() unable to find the Virtual Organization of the tapepool ") + tapepoolName + ".");
    }
    common::dataStructures::VirtualOrganization virtualOrganization;

    virtualOrganization.name = rset.columnString("VIRTUAL_ORGANIZATION_NAME");
    virtualOrganization.readMaxDrives = rset.columnUint64("READ_MAX_DRIVES");
    virtualOrganization.writeMaxDrives = rset.columnUint64("WRITE_MAX_DRIVES");
    virtualOrganization.comment = rset.columnString("USER_COMMENT");
    virtualOrganization.creationLog.username = rset.columnString("CREATION_LOG_USER_NAME");
    virtualOrganization.creationLog.host = rset.columnString("CREATION_LOG_HOST_NAME");
    virtualOrganization.creationLog.time = rset.columnUint64("CREATION_LOG_TIME");
    virtualOrganization.lastModificationLog.username = rset.columnString("LAST_UPDATE_USER_NAME");
    virtualOrganization.lastModificationLog.host = rset.columnString("LAST_UPDATE_HOST_NAME");
    virtualOrganization.lastModificationLog.time = rset.columnUint64("LAST_UPDATE_TIME");

    return virtualOrganization;
  } catch(exception::UserError &) {
    throw;
  } catch(exception::Exception &ex) {
    ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
    throw;
  }
}

//------------------------------------------------------------------------------
// getCachedVirtualOrganizationOfTapepool
//------------------------------------------------------------------------------
common::dataStructures::VirtualOrganization RdbmsCatalogue::getCachedVirtualOrganizationOfTapepool(const std::string & tapepoolName) const {
  try {
    auto getNonCachedValue = [&] {
      auto conn = m_connPool.getConn();
      return getVirtualOrganizationOfTapepool(conn,tapepoolName);
    };
    return m_tapepoolVirtualOrganizationCache.getCachedValue(tapepoolName,getNonCachedValue);
  } catch(exception::UserError &) {
    throw;
  } catch(exception::Exception &ex) {
    ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
    throw;
  }
}


575
576
577
578
579
580
581
582
583
584
585
586
587
//------------------------------------------------------------------------------
// modifyVirtualOrganizationName
//------------------------------------------------------------------------------
void RdbmsCatalogue::modifyVirtualOrganizationName(const common::dataStructures::SecurityIdentity& admin, const std::string& currentVoName, const std::string& newVoName) {
  try {
    const time_t now = time(nullptr);
    const char *const sql =
      "UPDATE VIRTUAL_ORGANIZATION SET "
        "VIRTUAL_ORGANIZATION_NAME = :NEW_VIRTUAL_ORGANIZATION_NAME,"
        "LAST_UPDATE_USER_NAME = :LAST_UPDATE_USER_NAME,"
        "LAST_UPDATE_HOST_NAME = :LAST_UPDATE_HOST_NAME,"
        "LAST_UPDATE_TIME = :LAST_UPDATE_TIME "
      "WHERE "
588
        "VIRTUAL_ORGANIZATION_NAME = :CUR_VIRTUAL_ORGANIZATION_NAME";
589
590
591
592
593
594
595
596
597
598
599
    auto conn = m_connPool.getConn();
    if(newVoName != currentVoName){
      if(virtualOrganizationExists(conn,newVoName)){
        throw exception::UserError(std::string("Cannot modify the virtual organization name ") + currentVoName +". The new name : " + newVoName+" already exists in the database.");
      }
    }
    auto stmt = conn.createStmt(sql);
    stmt.bindString(":NEW_VIRTUAL_ORGANIZATION_NAME", newVoName);
    stmt.bindString(":LAST_UPDATE_USER_NAME", admin.username);
    stmt.bindString(":LAST_UPDATE_HOST_NAME", admin.host);
    stmt.bindUint64(":LAST_UPDATE_TIME", now);
600
    stmt.bindString(":CUR_VIRTUAL_ORGANIZATION_NAME", currentVoName);
601
602
603
604
605
606
    stmt.executeNonQuery();

    if(0 == stmt.getNbAffectedRows()) {
      throw exception::UserError(std::string("Cannot modify virtual organization : ") + currentVoName +
        " because it does not exist");
    }
607
608
609
    
    m_tapepoolVirtualOrganizationCache.invalidate();
    
610
611
612
613
614
615
616
  } catch(exception::UserError &) {
    throw;
  } catch(exception::Exception &ex) {
    ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
    throw;
  }
}
617

618
void RdbmsCatalogue::modifyVirtualOrganizationReadMaxDrives(const common::dataStructures::SecurityIdentity &admin, const std::string &voName, const uint64_t readMaxDrives){
619
620
621
622
  try {
    const time_t now = time(nullptr);
    const char *const sql =
      "UPDATE VIRTUAL_ORGANIZATION SET "
623
        "READ_MAX_DRIVES = :READ_MAX_DRIVES,"
624
625
626
627
628
629
630
631
        "LAST_UPDATE_USER_NAME = :LAST_UPDATE_USER_NAME,"
        "LAST_UPDATE_HOST_NAME = :LAST_UPDATE_HOST_NAME,"
        "LAST_UPDATE_TIME = :LAST_UPDATE_TIME "
      "WHERE "
        "VIRTUAL_ORGANIZATION_NAME = :VIRTUAL_ORGANIZATION_NAME";
    auto conn = m_connPool.getConn();
   
    auto stmt = conn.createStmt(sql);
632
    stmt.bindUint64(":READ_MAX_DRIVES", readMaxDrives);
633
634
635
636
637
638
639
640
641
642
    stmt.bindString(":LAST_UPDATE_USER_NAME", admin.username);
    stmt.bindString(":LAST_UPDATE_HOST_NAME", admin.host);
    stmt.bindUint64(":LAST_UPDATE_TIME", now);
    stmt.bindString(":VIRTUAL_ORGANIZATION_NAME", voName);
    stmt.executeNonQuery();

    if(0 == stmt.getNbAffectedRows()) {
      throw exception::UserError(std::string("Cannot modify virtual organization : ") + voName +
        " because it does not exist");
    }
643
644
645
    
    m_tapepoolVirtualOrganizationCache.invalidate();
    
646
647
648
649
650
651
652
653
  } catch(exception::UserError &) {
    throw;
  } catch(exception::Exception &ex) {
    ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
    throw;
  }
}

654
void RdbmsCatalogue::modifyVirtualOrganizationWriteMaxDrives(const common::dataStructures::SecurityIdentity &admin, const std::string &voName, const uint64_t writeMaxDrives){
655
656
657
658
  try {
    const time_t now = time(nullptr);
    const char *const sql =
      "UPDATE VIRTUAL_ORGANIZATION SET "
659
        "WRITE_MAX_DRIVES = :WRITE_MAX_DRIVES,"
660
661
662
663
664
665
666
667
        "LAST_UPDATE_USER_NAME = :LAST_UPDATE_USER_NAME,"
        "LAST_UPDATE_HOST_NAME = :LAST_UPDATE_HOST_NAME,"
        "LAST_UPDATE_TIME = :LAST_UPDATE_TIME "
      "WHERE "
        "VIRTUAL_ORGANIZATION_NAME = :VIRTUAL_ORGANIZATION_NAME";
    auto conn = m_connPool.getConn();
   
    auto stmt = conn.createStmt(sql);
668
    stmt.bindUint64(":WRITE_MAX_DRIVES", writeMaxDrives);
669
670
671
672
673
674
675
676
677
678
    stmt.bindString(":LAST_UPDATE_USER_NAME", admin.username);
    stmt.bindString(":LAST_UPDATE_HOST_NAME", admin.host);
    stmt.bindUint64(":LAST_UPDATE_TIME", now);
    stmt.bindString(":VIRTUAL_ORGANIZATION_NAME", voName);
    stmt.executeNonQuery();

    if(0 == stmt.getNbAffectedRows()) {
      throw exception::UserError(std::string("Cannot modify virtual organization : ") + voName +
        " because it does not exist");
    }
679
680
681
    
    m_tapepoolVirtualOrganizationCache.invalidate();
    
682
683
684
685
686
687
688
689
  } catch(exception::UserError &) {
    throw;
  } catch(exception::Exception &ex) {
    ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
    throw;
  }
}

690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
void RdbmsCatalogue::modifyVirtualOrganizationComment(const common::dataStructures::SecurityIdentity& admin, const std::string& voName, const std::string& comment) {
try {
    const time_t now = time(nullptr);
    const char *const sql =
      "UPDATE VIRTUAL_ORGANIZATION SET "
        "USER_COMMENT = :USER_COMMENT,"
        "LAST_UPDATE_USER_NAME = :LAST_UPDATE_USER_NAME,"
        "LAST_UPDATE_HOST_NAME = :LAST_UPDATE_HOST_NAME,"
        "LAST_UPDATE_TIME = :LAST_UPDATE_TIME "
      "WHERE "
        "VIRTUAL_ORGANIZATION_NAME = :VIRTUAL_ORGANIZATION_NAME";
    auto conn = m_connPool.getConn();
   
    auto stmt = conn.createStmt(sql);
    stmt.bindString(":USER_COMMENT", comment);
    stmt.bindString(":LAST_UPDATE_USER_NAME", admin.username);
    stmt.bindString(":LAST_UPDATE_HOST_NAME", admin.host);
    stmt.bindUint64(":LAST_UPDATE_TIME", now);
    stmt.bindString(":VIRTUAL_ORGANIZATION_NAME", voName);
    stmt.executeNonQuery();

    if(0 == stmt.getNbAffectedRows()) {
      throw exception::UserError(std::string("Cannot modify virtual organization : ") + voName +
        " because it does not exist");
    }
  } catch(exception::UserError &) {
    throw;
  } catch(exception::Exception &ex) {
    ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
    throw;
  }
}


724
//------------------------------------------------------------------------------
725
726
// createStorageClass
//------------------------------------------------------------------------------
727
void RdbmsCatalogue::createStorageClass(
Steven Murray's avatar
Steven Murray committed
728
  const common::dataStructures::SecurityIdentity &admin,
729
  const common::dataStructures::StorageClass &storageClass) {
Steven Murray's avatar
Steven Murray committed
730
  try {
731
732

    if(storageClass.name.empty()) {
733
734
      throw UserSpecifiedAnEmptyStringStorageClassName("Cannot create storage class because the storage class name is"
        " an empty string");
735
736
737
    }

    if(storageClass.comment.empty()) {
738
      throw UserSpecifiedAnEmptyStringComment("Cannot create storage class because the comment is an empty string");
739
    }
740
741
742
743
744
745
    
    std::string vo = storageClass.vo.name;
    
    if(vo.empty()) {
      throw UserSpecifiedAnEmptyStringVo("Cannot create storage class because the vo is an empty string");
    }
746

747
    auto conn = m_connPool.getConn();
748
749
    if(storageClassExists(conn, storageClass.name)) {
      throw exception::UserError(std::string("Cannot create storage class : ") +
750
        storageClass.name + " because it already exists");
751
    }
752
753
754
755
    if(!virtualOrganizationExists(conn,vo)){
      throw exception::UserError(std::string("Cannot create storage class : ") +
        storageClass.name + " because the vo : " + vo + " does not exist");
    }
756
    const uint64_t storageClassId = getNextStorageClassId(conn);
757
    const time_t now = time(nullptr);
Steven Murray's avatar
Steven Murray committed
758
759
    const char *const sql =
      "INSERT INTO STORAGE_CLASS("
760
        "STORAGE_CLASS_ID,"
Steven Murray's avatar
Steven Murray committed
761
762
        "STORAGE_CLASS_NAME,"
        "NB_COPIES,"
763
        "VIRTUAL_ORGANIZATION_ID,"
Steven Murray's avatar
Steven Murray committed
764
765
766
767
768
769
770
771
772
773

        "USER_COMMENT,"

        "CREATION_LOG_USER_NAME,"
        "CREATION_LOG_HOST_NAME,"
        "CREATION_LOG_TIME,"

        "LAST_UPDATE_USER_NAME,"
        "LAST_UPDATE_HOST_NAME,"
        "LAST_UPDATE_TIME)"
774
      "VALUES("
775
        ":STORAGE_CLASS_ID,"
Steven Murray's avatar
Steven Murray committed
776
777
        ":STORAGE_CLASS_NAME,"
        ":NB_COPIES,"
778
        "(SELECT VIRTUAL_ORGANIZATION_ID FROM VIRTUAL_ORGANIZATION WHERE VIRTUAL_ORGANIZATION_NAME = :VO),"
Steven Murray's avatar
Steven Murray committed
779
780
781
782
783
784
785

        ":USER_COMMENT,"

        ":CREATION_LOG_USER_NAME,"
        ":CREATION_LOG_HOST_NAME,"
        ":CREATION_LOG_TIME,"

786
787
788
        ":LAST_UPDATE_USER_NAME,"
        ":LAST_UPDATE_HOST_NAME,"
        ":LAST_UPDATE_TIME)";
789
    auto stmt = conn.createStmt(sql);
Steven Murray's avatar
Steven Murray committed
790

791
    stmt.bindUint64(":STORAGE_CLASS_ID", storageClassId);
792
793
    stmt.bindString(":STORAGE_CLASS_NAME", storageClass.name);
    stmt.bindUint64(":NB_COPIES", storageClass.nbCopies);
794
795
    stmt.bindString(":VO",vo);
    
796
    stmt.bindString(":USER_COMMENT", storageClass.comment);
Steven Murray's avatar
Steven Murray committed
797

798
799
800
    stmt.bindString(":CREATION_LOG_USER_NAME", admin.username);
    stmt.bindString(":CREATION_LOG_HOST_NAME", admin.host);
    stmt.bindUint64(":CREATION_LOG_TIME", now);
Steven Murray's avatar
Steven Murray committed
801

802
803
804
    stmt.bindString(":LAST_UPDATE_USER_NAME", admin.username);
    stmt.bindString(":LAST_UPDATE_HOST_NAME", admin.host);
    stmt.bindUint64(":LAST_UPDATE_TIME", now);
805

806
    stmt.executeNonQuery();
807
  } catch(exception::UserError &) {
808
    throw;
809
810
811
  } catch(exception::Exception &ex) {
    ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
    throw;
812
813
814
815
816
817
  }
}

//------------------------------------------------------------------------------
// storageClassExists
//------------------------------------------------------------------------------
818
bool RdbmsCatalogue::storageClassExists(rdbms::Conn &conn,
819
  const std::string &storageClassName) const {
820
821
822
823
824
825
826
  try {
    const char *const sql =
      "SELECT "
        "STORAGE_CLASS_NAME AS STORAGE_CLASS_NAME "
      "FROM "
        "STORAGE_CLASS "
      "WHERE "
827
        "STORAGE_CLASS_NAME = :STORAGE_CLASS_NAME";
828
    auto stmt = conn.createStmt(sql);
829
    stmt.bindString(":STORAGE_CLASS_NAME", storageClassName);
830
    auto rset = stmt.executeQuery();
831
    return rset.next();
832
833
  } catch(exception::UserError &) {
    throw;
834
835
836
  } catch(exception::Exception &ex) {
    ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
    throw;
Steven Murray's avatar
Steven Murray committed
837
  }
838
839
840
841
842
}

//------------------------------------------------------------------------------
// deleteStorageClass
//------------------------------------------------------------------------------
843
void RdbmsCatalogue::deleteStorageClass(const std::string &storageClassName) {
844
  try {
845
846
847
848
849
850
851
852
853
854
855
    auto conn = m_connPool.getConn();

    if(storageClassIsUsedByArchiveRoutes(conn, storageClassName)) {
      throw UserSpecifiedStorageClassUsedByArchiveRoutes(std::string("The ") + storageClassName +
        " storage class is being used by one or more archive routes");
    }

    if(storageClassIsUsedByArchiveFiles(conn, storageClassName)) {
      throw UserSpecifiedStorageClassUsedByArchiveFiles(std::string("The ") + storageClassName +
        " storage class is being used by one or more archive files");
    }
856
857
858
859
860
    
    if(storageClassIsUsedByFileRecyleLogs(conn,storageClassName)){
      throw UserSpecifiedStorageClassUsedByFileRecycleLogs(std::string("The ") + storageClassName +
        " storage class is being used by one or more file in the recycle logs");
    }
861

862
863
864
865
    const char *const sql =
      "DELETE FROM "
        "STORAGE_CLASS "
      "WHERE "
866
        "STORAGE_CLASS_NAME = :STORAGE_CLASS_NAME";
867
    auto stmt = conn.createStmt(sql);
868

869
    stmt.bindString(":STORAGE_CLASS_NAME", storageClassName);
870

871
    stmt.executeNonQuery();
872
    if(0 == stmt.getNbAffectedRows()) {
873
      throw exception::UserError(std::string("Cannot delete storage-class : ") +
874
        storageClassName + " because it does not exist");
875
    }
876
  } catch(exception::UserError &) {
877
    throw;
878
879
880
  } catch(exception::Exception &ex) {
    ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
    throw;
881
  }
Steven Murray's avatar
Steven Murray committed
882
}
883

884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
//------------------------------------------------------------------------------
// MediaTypeIsUsedByTapes
//------------------------------------------------------------------------------
bool RdbmsCatalogue::mediaTypeIsUsedByTapes(rdbms::Conn &conn, const std::string &name) const {
  try {
    const char *const sql =
      "SELECT"                                          "\n"
        "MEDIA_TYPE.MEDIA_TYPE_NAME"                    "\n"
      "FROM"                                            "\n"
        "TAPE"                                          "\n"
      "INNER JOIN"                                      "\n"
        "MEDIA_TYPE"                                    "\n"
      "ON"                                              "\n"
        "TAPE.MEDIA_TYPE_ID = MEDIA_TYPE.MEDIA_TYPE_ID" "\n"
      "WHERE"                                           "\n"
        "MEDIA_TYPE.MEDIA_TYPE_NAME = :MEDIA_TYPE_NAME";
    auto stmt = conn.createStmt(sql);
    stmt.bindString(":MEDIA_TYPE_NAME", name);
    auto rset = stmt.executeQuery();
    return rset.next();
  } catch(exception::UserError &) {
    throw;
  } catch(exception::Exception &ex) {
    ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
    throw;
  }
}

912
//------------------------------------------------------------------------------
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
// storageClassIsUsedByArchiveRoutes
//------------------------------------------------------------------------------
bool RdbmsCatalogue::storageClassIsUsedByArchiveRoutes(rdbms::Conn &conn, const std::string &storageClassName) const {
  try {
    const char *const sql =
      "SELECT "
        "STORAGE_CLASS.STORAGE_CLASS_NAME AS STORAGE_CLASS_NAME "
      "FROM "
        "ARCHIVE_ROUTE "
      "INNER JOIN "
        "STORAGE_CLASS "
      "ON "
        "ARCHIVE_ROUTE.STORAGE_CLASS_ID = STORAGE_CLASS.STORAGE_CLASS_ID "
      "WHERE "
        "STORAGE_CLASS_NAME = :STORAGE_CLASS_NAME";
    auto stmt = conn.createStmt(sql);
    stmt.bindString(":STORAGE_CLASS_NAME", storageClassName);
    auto rset = stmt.executeQuery();
    return rset.next();
  } catch(exception::UserError &) {
    throw;
  } catch(exception::Exception &ex) {
    ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
    throw;
  }
}

//------------------------------------------------------------------------------
// storageClassIsUsedByARchiveFiles
//------------------------------------------------------------------------------
bool RdbmsCatalogue::storageClassIsUsedByArchiveFiles(rdbms::Conn &conn, const std::string &storageClassName) const {
  try {
    const char *const sql =
      "SELECT "
        "STORAGE_CLASS.STORAGE_CLASS_NAME AS STORAGE_CLASS_NAME "
      "FROM "
        "ARCHIVE_FILE "
      "INNER JOIN "
        "STORAGE_CLASS "
      "ON "
        "ARCHIVE_FILE.STORAGE_CLASS_ID = STORAGE_CLASS.STORAGE_CLASS_ID "
      "WHERE "
        "STORAGE_CLASS_NAME = :STORAGE_CLASS_NAME";
    auto stmt = conn.createStmt(sql);
    stmt.bindString(":STORAGE_CLASS_NAME", storageClassName);
    auto rset = stmt.executeQuery();
    return rset.next();
  } catch(exception::UserError &) {
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
    throw;
  } catch(exception::Exception &ex) {
    ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
    throw;
  }
}

//------------------------------------------------------------------------------
// storageClassIsUsedByFileRecyleLogs
//------------------------------------------------------------------------------
bool RdbmsCatalogue::storageClassIsUsedByFileRecyleLogs(rdbms::Conn &conn, const std::string &storageClassName) const {
  try {
    const char *const sql =
      "SELECT "
        "STORAGE_CLASS.STORAGE_CLASS_NAME AS STORAGE_CLASS_NAME "
      "FROM "
        "FILE_RECYCLE_LOG "
      "INNER JOIN "
        "STORAGE_CLASS "
      "ON "
        "FILE_RECYCLE_LOG.STORAGE_CLASS_ID = STORAGE_CLASS.STORAGE_CLASS_ID "
      "WHERE "
        "STORAGE_CLASS_NAME = :STORAGE_CLASS_NAME";
    auto stmt = conn.createStmt(sql);
    stmt.bindString(":STORAGE_CLASS_NAME", storageClassName);
    auto rset = stmt.executeQuery();
    return rset.next();
  } catch(exception::UserError &) {
989
990
991
992
    throw;
  } catch(exception::Exception &ex) {
    ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
    throw;
993
994
995
996
997
998
999
1000
  }
}

//------------------------------------------------------------------------------
// virtualOrganizationIsUsedByStorageClasses
//------------------------------------------------------------------------------
bool RdbmsCatalogue::virtualOrganizationIsUsedByStorageClasses(rdbms::Conn &conn, const std::string &voName) const {
  try {