diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 23c2b5f380b3ccc692a91a0b4b8b66ea3a11679a..25f62f9d3acba9d9cd4c649cefa6c760eb479426 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -1,8 +1,10 @@ cmake_minimum_required (VERSION 2.6) set (COMMON_LIB_SRC_FILES + FileStatus.cpp SmartFd.cpp Timer.cpp + UserIdentity.cpp Utils.cpp exception/Backtrace.cpp exception/Errnum.cpp diff --git a/scheduler/FileStatus.cpp b/common/FileStatus.cpp similarity index 98% rename from scheduler/FileStatus.cpp rename to common/FileStatus.cpp index d0e99dbb2fad2c19954ee5a95d3a4ff8880b1b1b..914d524200c57629fc0ef7aaabff50cf88f0c9ff 100644 --- a/scheduler/FileStatus.cpp +++ b/common/FileStatus.cpp @@ -16,7 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "scheduler/FileStatus.hpp" +#include "common/FileStatus.hpp" //------------------------------------------------------------------------------ // constructor diff --git a/scheduler/FileStatus.hpp b/common/FileStatus.hpp similarity index 98% rename from scheduler/FileStatus.hpp rename to common/FileStatus.hpp index 986bf517b7258dcddc4afb291ba7d864da04a02b..80449c917fa633f32acc5fa9e46979b5a6c32bc2 100644 --- a/scheduler/FileStatus.hpp +++ b/common/FileStatus.hpp @@ -18,7 +18,7 @@ #pragma once -#include "scheduler/UserIdentity.hpp" +#include "common/UserIdentity.hpp" #include <string> diff --git a/scheduler/UserIdentity.cpp b/common/UserIdentity.cpp similarity index 97% rename from scheduler/UserIdentity.cpp rename to common/UserIdentity.cpp index b421676411b2d8198e11f5f2c1cf970848a6ff6d..c72c97b43024de4ab7748921d25c6f859ca01301 100644 --- a/scheduler/UserIdentity.cpp +++ b/common/UserIdentity.cpp @@ -16,9 +16,10 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "scheduler/UserIdentity.hpp" -#include "ostream" +#include "common/UserIdentity.hpp" + #include <limits> +#include <ostream> //------------------------------------------------------------------------------ // constructor diff --git a/scheduler/UserIdentity.hpp b/common/UserIdentity.hpp similarity index 100% rename from scheduler/UserIdentity.hpp rename to common/UserIdentity.hpp diff --git a/nameserver/MockNameServer.hpp b/nameserver/MockNameServer.hpp index 1be5739f43a336616aca1e13df34f096d2b5a554..db233543dfd5d954827e1109b957908bf13cc6c9 100644 --- a/nameserver/MockNameServer.hpp +++ b/nameserver/MockNameServer.hpp @@ -18,10 +18,10 @@ #pragma once -#include "scheduler/DirIterator.hpp" +#include "common/UserIdentity.hpp" #include "nameserver/NameServer.hpp" +#include "scheduler/DirIterator.hpp" #include "scheduler/SecurityIdentity.hpp" -#include "scheduler/UserIdentity.hpp" #include <list> #include <string> diff --git a/nameserver/NameServer.hpp b/nameserver/NameServer.hpp index ecabae546de8a637807f80a904207fa0f81e4c4d..cff5b3c0a4b860c6adff3f019d1eabacc36fc832 100644 --- a/nameserver/NameServer.hpp +++ b/nameserver/NameServer.hpp @@ -18,8 +18,8 @@ #pragma once +#include "common/FileStatus.hpp" #include "scheduler/DirIterator.hpp" -#include "scheduler/FileStatus.hpp" #include "scheduler/SecurityIdentity.hpp" #include <string> diff --git a/objectstore/CreationLog.hpp b/objectstore/CreationLog.hpp index 592c4cb3e626d95ac1fac67067a1dc958abf84de..1045c43382eeea4d4d988734942d23bbf83957b6 100644 --- a/objectstore/CreationLog.hpp +++ b/objectstore/CreationLog.hpp @@ -16,12 +16,13 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "common/UserIdentity.hpp" +#include "objectstore/cta.pb.h" +#include "scheduler/CreationLog.hpp" + #include <string> #include <stdint.h> #include <limits> -#include "scheduler/CreationLog.hpp" -#include "scheduler/UserIdentity.hpp" -#include "objectstore/cta.pb.h" namespace cta { namespace objectstore { /** diff --git a/objectstore/UserIdentity.hpp b/objectstore/UserIdentity.hpp index 0b3f1d5d88059fcd3c94061db5afe0534c5d53cc..151ca5852339831f5a190da319e535ad10c866ce 100644 --- a/objectstore/UserIdentity.hpp +++ b/objectstore/UserIdentity.hpp @@ -16,10 +16,11 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "common/UserIdentity.hpp" +#include "objectstore/cta.pb.h" + #include <string> #include <stdint.h> -#include "objectstore/cta.pb.h" -#include "scheduler/UserIdentity.hpp" namespace cta { namespace objectstore { diff --git a/scheduler/AdminHost.hpp b/scheduler/AdminHost.hpp index 1d5d673b6416a39eb74955db26ce0830eb05944e..44f9a8df5aeb9eeb3d011652fa616f3b05539f26 100644 --- a/scheduler/AdminHost.hpp +++ b/scheduler/AdminHost.hpp @@ -18,8 +18,8 @@ #pragma once +#include "common/UserIdentity.hpp" #include "scheduler/ConfigurationItem.hpp" -#include "scheduler/UserIdentity.hpp" #include <string> diff --git a/scheduler/AdminUser.hpp b/scheduler/AdminUser.hpp index d2356affd01179a5a1631ed5efc3d1a62bebbd29..f5cf542f2b7af45a6e5cee65a53787e179f65bb5 100644 --- a/scheduler/AdminUser.hpp +++ b/scheduler/AdminUser.hpp @@ -18,8 +18,8 @@ #pragma once +#include "common/UserIdentity.hpp" #include "scheduler/ConfigurationItem.hpp" -#include "scheduler/UserIdentity.hpp" #include <string> diff --git a/scheduler/ArchivalRoute.hpp b/scheduler/ArchivalRoute.hpp index eaa0da3a8bd619330f9d42ae441e2de6927f23ca..66827156a933487f2c07f718e24e4e2ff872babc 100644 --- a/scheduler/ArchivalRoute.hpp +++ b/scheduler/ArchivalRoute.hpp @@ -18,7 +18,7 @@ #pragma once -#include "scheduler/UserIdentity.hpp" +#include "common/UserIdentity.hpp" #include "scheduler/CreationLog.hpp" #include <stdint.h> diff --git a/scheduler/CMakeLists.txt b/scheduler/CMakeLists.txt index 72bcfef99922693181509d79c1f85b85d521c78d..67c8c67effe382aac742787f4064f7d301ead582 100644 --- a/scheduler/CMakeLists.txt +++ b/scheduler/CMakeLists.txt @@ -22,7 +22,6 @@ set (CTA_SCHEDULER_SRC_FILES DiskException.cpp DriveQuota.cpp FileAttribute.cpp - FileStatus.cpp FileSystemDirEntry.cpp FileSystemNode.cpp FileSystemStorageClass.cpp @@ -50,7 +49,6 @@ set (CTA_SCHEDULER_SRC_FILES TapeCopyLocation.cpp TapeException.cpp TapePool.cpp - UserIdentity.cpp UserGroup.cpp UserRequest.cpp VO.cpp) diff --git a/scheduler/ConfigurationItem.hpp b/scheduler/ConfigurationItem.hpp index a1b15099a723e38654ee83ec6201f0d5d5e422bc..ad4f1f2f9923d4b4f61f6316872a2a16d31f260f 100644 --- a/scheduler/ConfigurationItem.hpp +++ b/scheduler/ConfigurationItem.hpp @@ -18,7 +18,7 @@ #pragma once -#include "scheduler/UserIdentity.hpp" +#include "common/UserIdentity.hpp" #include <string> #include <time.h> diff --git a/scheduler/CreationLog.hpp b/scheduler/CreationLog.hpp index c55c00e06708522651781c9c6247de5b4239e837..73ae4224abdf7232cd3638fbe573d9ee77d28eb1 100644 --- a/scheduler/CreationLog.hpp +++ b/scheduler/CreationLog.hpp @@ -18,7 +18,7 @@ #pragma once -#include "scheduler/UserIdentity.hpp" +#include "common/UserIdentity.hpp" #include <string> diff --git a/scheduler/FileSystemNode.cpp b/scheduler/FileSystemNode.cpp index 9cd66f8523dbd8cfff5108fab60ffcc375172b31..c46f209d6fac4ead34e9456d690e832a091ef88c 100644 --- a/scheduler/FileSystemNode.cpp +++ b/scheduler/FileSystemNode.cpp @@ -62,7 +62,7 @@ void cta::FileSystemNode::deleteAndClearChildren() { //------------------------------------------------------------------------------ cta::FileSystemNode &cta::FileSystemNode::getParent() { if(NULL == m_parent) { - throw Exception("Internal error"); + throw exception::Exception("Internal error"); } return *m_parent; @@ -73,7 +73,7 @@ cta::FileSystemNode &cta::FileSystemNode::getParent() { //------------------------------------------------------------------------------ const cta::FileSystemNode &cta::FileSystemNode::getParent() const { if(NULL == m_parent) { - throw Exception("Internal error"); + throw exception::Exception("Internal error"); } return *m_parent; @@ -105,7 +105,8 @@ std::list<cta::DirEntry> cta::FileSystemNode::getDirEntries() m_children.begin(); itor != m_children.end(); itor++) { const FileSystemNode *const childNode = itor->second; if(NULL == childNode) { - throw(Exception("getDirEntries encountered a NULL child pointer")); + throw(exception::Exception(std::string(__FUNCTION__) + " encountered a" + " NULL child pointer")); } const cta::FileSystemDirEntry &childEntry = childNode->getFileSystemEntry(); @@ -120,7 +121,7 @@ std::list<cta::DirEntry> cta::FileSystemNode::getDirEntries() void cta::FileSystemNode::addChild(FileSystemNode *const child) { if(childExists(child->getFileSystemEntry().getEntry().getName())) { delete child; - throw Exception("FileSystemNode already exists"); + throw exception::Exception("FileSystemNode already exists"); } child->m_parent = this; @@ -149,10 +150,10 @@ bool cta::FileSystemNode::childExists(const std::string &name) const { cta::FileSystemNode &cta::FileSystemNode::getChild(const std::string &name) { std::map<std::string, FileSystemNode*>::iterator itor = m_children.find(name); if(m_children.end() == itor) { - throw Exception("No such file or directory"); + throw exception::Exception("No such file or directory"); } if(NULL == itor->second) { - throw Exception("Unexpected NULL pointer"); + throw exception::Exception("Unexpected NULL pointer"); } return *(itor->second); } @@ -165,10 +166,10 @@ const cta::FileSystemNode &cta::FileSystemNode::getChild( std::map<std::string, FileSystemNode*>::const_iterator itor = m_children.find(name); if(m_children.end() == itor) { - throw Exception("No such file or directory"); + throw exception::Exception("No such file or directory"); } if(NULL == itor->second) { - throw Exception("Unexpected NULL pointer"); + throw exception::Exception("Unexpected NULL pointer"); } return *(itor->second); } @@ -179,7 +180,7 @@ const cta::FileSystemNode &cta::FileSystemNode::getChild( void cta::FileSystemNode::deleteChild(const std::string &name) { std::map<std::string, FileSystemNode*>::iterator itor = m_children.find(name); if(m_children.end() == itor) { - throw Exception("No such file or directory"); + throw exception::Exception("No such file or directory"); } delete itor->second; diff --git a/scheduler/FileSystemStorageClass.cpp b/scheduler/FileSystemStorageClass.cpp index dfeb70fda992c3dfcb299deccc01e1813f400175..861badd21311ed401c8a41fd0cf475ad91b35d6d 100644 --- a/scheduler/FileSystemStorageClass.cpp +++ b/scheduler/FileSystemStorageClass.cpp @@ -60,7 +60,7 @@ void cta::FileSystemStorageClass::incUsageCount() { message << "Cannot increment usage count of storage class " << m_storageClass.getName() << " because its maximum value of UINT64_MAX" " has already been reached"; - throw Exception(message.str()); + throw exception::Exception(message.str()); } m_usageCount++; } @@ -73,7 +73,7 @@ void cta::FileSystemStorageClass::decUsageCount() { std::ostringstream message; message << "Cannot decrement usage count of storage class " << m_storageClass.getName() << " because it is already at zero"; - throw Exception(message.str()); + throw exception::Exception(message.str()); } m_usageCount--; } diff --git a/scheduler/FileSystemStorageClass.hpp b/scheduler/FileSystemStorageClass.hpp index e7d36f6e06f8d37bdcc5c730b47f54665c8fd0b5..d5c5f4beba243bc981cbca33e135d5b9231aa9cf 100644 --- a/scheduler/FileSystemStorageClass.hpp +++ b/scheduler/FileSystemStorageClass.hpp @@ -19,9 +19,8 @@ #pragma once #include "common/exception/Exception.hpp" +#include "common/UserIdentity.hpp" #include "scheduler/StorageClass.hpp" -#include "scheduler/UserIdentity.hpp" -using cta::exception::Exception; #include <sstream> #include <string> diff --git a/scheduler/FileSystemStorageClasses.cpp b/scheduler/FileSystemStorageClasses.cpp index c52911becc6c1883110b9781b21298569e3d5c81..cfb537ed9c982a979f19623213deac449ebaaa2a 100644 --- a/scheduler/FileSystemStorageClasses.cpp +++ b/scheduler/FileSystemStorageClasses.cpp @@ -33,7 +33,7 @@ void cta::FileSystemStorageClasses::createStorageClass( StorageClass storageClass(name, nbCopies, creationLog); m_storageClasses[name] = storageClass; } catch(std::exception &ex) { - throw Exception(std::string("Failed to create storage class: ") + + throw exception::Exception(std::string("Failed to create storage class: ") + ex.what()); } } @@ -48,7 +48,7 @@ void cta::FileSystemStorageClasses::checkStorageClassDoesNotAlreadyExist( if(itor != m_storageClasses.end()) { std::ostringstream msg; msg << "Storage class " << name << " already exists"; - throw Exception(msg.str()); + throw exception::Exception(msg.str()); } } @@ -62,7 +62,7 @@ void cta::FileSystemStorageClasses::deleteStorageClass( checkStorageClassIsNotInUse(name); m_storageClasses.erase(name); } catch(std::exception &ex) { - throw Exception(std::string("Failed to delete storage class: ") + + throw exception::Exception(std::string("Failed to delete storage class: ") + ex.what()); } } @@ -77,7 +77,7 @@ void cta::FileSystemStorageClasses::checkStorageClassExists( if(itor == m_storageClasses.end()) { std::ostringstream msg; msg << "Storage class " << name << " does not exist"; - throw Exception(msg.str()); + throw exception::Exception(msg.str()); } } @@ -97,7 +97,7 @@ void cta::FileSystemStorageClasses::checkStorageClassIsNotInUse( if(itor->second.getUsageCount() > 0) { std::ostringstream message; message << "Storage class " << name << " is in use"; - throw Exception(message.str()); + throw exception::Exception(message.str()); } } @@ -124,7 +124,7 @@ const cta::StorageClass &cta::FileSystemStorageClasses::getStorageClass( if(itor == m_storageClasses.end()) { std::ostringstream message; message << "Storage class " << name << " does not exist"; - throw Exception(message.str()); + throw exception::Exception(message.str()); } return itor->second.getStorageClass(); } @@ -146,7 +146,7 @@ void cta::FileSystemStorageClasses::incStorageClassUsageCount( if(itor == m_storageClasses.end()) { std::ostringstream message; message << "Storage class " << name << " does not exist"; - throw Exception(message.str()); + throw exception::Exception(message.str()); } itor->second.incUsageCount(); @@ -169,7 +169,7 @@ void cta::FileSystemStorageClasses::decStorageClassUsageCount( if(itor == m_storageClasses.end()) { std::ostringstream message; message << "Storage class " << name << " does not exist"; - throw Exception(message.str()); + throw exception::Exception(message.str()); } itor->second.decUsageCount(); diff --git a/scheduler/FileSystemStorageClasses.hpp b/scheduler/FileSystemStorageClasses.hpp index 31edc246357dded47f54a684aaa584cfd6f9375d..ad558f12e3171b2a25c15838e8bf400790ec573c 100644 --- a/scheduler/FileSystemStorageClasses.hpp +++ b/scheduler/FileSystemStorageClasses.hpp @@ -18,8 +18,8 @@ #pragma once +#include "common/UserIdentity.hpp" #include "scheduler/FileSystemStorageClass.hpp" -#include "scheduler/UserIdentity.hpp" #include <list> #include <map> diff --git a/scheduler/MockSchedulerDatabase.cpp b/scheduler/MockSchedulerDatabase.cpp index c44e4e85c0f0d8556e38cc561d82639e12119045..fda369e7214ff557d1d45f9f6bd78d17b2c7bb35 100644 --- a/scheduler/MockSchedulerDatabase.cpp +++ b/scheduler/MockSchedulerDatabase.cpp @@ -17,6 +17,7 @@ */ #include "common/exception/Exception.hpp" +#include "common/UserIdentity.hpp" #include "nameserver/NameServer.hpp" #include "scheduler/AdminHost.hpp" #include "scheduler/AdminUser.hpp" @@ -35,7 +36,6 @@ #include "scheduler/StorageClass.hpp" #include "scheduler/Tape.hpp" #include "scheduler/TapePool.hpp" -#include "scheduler/UserIdentity.hpp" #include <iostream> #include <memory> diff --git a/scheduler/Scheduler.cpp b/scheduler/Scheduler.cpp index bce1330dbdc58e27d263fb5633329a61de2897fd..d395691605e18ffecf14557b2ca323abc799b807 100644 --- a/scheduler/Scheduler.cpp +++ b/scheduler/Scheduler.cpp @@ -17,6 +17,7 @@ */ #include "common/exception/Exception.hpp" +#include "common/UserIdentity.hpp" #include "common/Utils.hpp" #include "nameserver/NameServer.hpp" #include "remotens/RemoteNS.hpp" @@ -36,7 +37,6 @@ #include "scheduler/StorageClass.hpp" #include "scheduler/Tape.hpp" #include "scheduler/TapePool.hpp" -#include "scheduler/UserIdentity.hpp" #include <iostream> #include <sstream> diff --git a/scheduler/SchedulerDatabaseTest.cpp b/scheduler/SchedulerDatabaseTest.cpp index 98f025e2dc084928f108000ed6addcd9672b5618..1c9b0736fc8b23ff3519d25696f045d5d41b616f 100644 --- a/scheduler/SchedulerDatabaseTest.cpp +++ b/scheduler/SchedulerDatabaseTest.cpp @@ -16,6 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "common/UserIdentity.hpp" #include "scheduler/AdminHost.hpp" #include "scheduler/AdminUser.hpp" #include "scheduler/ArchivalRoute.hpp" @@ -24,7 +25,6 @@ #include "scheduler/SchedulerDatabase.hpp" #include "scheduler/SchedulerDatabaseFactory.hpp" #include "scheduler/SecurityIdentity.hpp" -#include "scheduler/UserIdentity.hpp" #include "OStoreDB/OStoreDBFactory.hpp" #include <exception> diff --git a/scheduler/SecurityIdentity.hpp b/scheduler/SecurityIdentity.hpp index 9d14953212520a9fedf2bc17f07ec553aaec29c6..8be4e46083f708c9875dd8661494baa88c7a940f 100644 --- a/scheduler/SecurityIdentity.hpp +++ b/scheduler/SecurityIdentity.hpp @@ -18,7 +18,7 @@ #pragma once -#include "scheduler/UserIdentity.hpp" +#include "common/UserIdentity.hpp" #include <string> diff --git a/scheduler/Tape.hpp b/scheduler/Tape.hpp index 5c8ea60001f167a4a5722af2e9f9d70b17e78dfa..d3a64af08f4643bc080f80bc6f33a2f17652a341 100644 --- a/scheduler/Tape.hpp +++ b/scheduler/Tape.hpp @@ -18,8 +18,8 @@ #pragma once +#include "common/UserIdentity.hpp" #include "scheduler/ConfigurationItem.hpp" -#include "scheduler/UserIdentity.hpp" #include <stdint.h> #include <string> diff --git a/scheduler/UserIdentityTest.cpp b/scheduler/UserIdentityTest.cpp index 3878dafa0f41920f0bcf18520ab91f944fae9e35..a7dec0a0740896b28083eefbf391f08e9c15d8c9 100644 --- a/scheduler/UserIdentityTest.cpp +++ b/scheduler/UserIdentityTest.cpp @@ -16,7 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "scheduler/UserIdentity.hpp" +#include "common/UserIdentity.hpp" #include <gtest/gtest.h> diff --git a/xroot_plugins/XrdProFile.cpp b/xroot_plugins/XrdProFile.cpp index 4a25ab37f3b618959e22f1a1dab894e8affb55f2..2779e0e24ad6cb0640752765fc9976055bacb7c4 100644 --- a/xroot_plugins/XrdProFile.cpp +++ b/xroot_plugins/XrdProFile.cpp @@ -17,6 +17,7 @@ */ #include "common/exception/Exception.hpp" +#include "common/UserIdentity.hpp" #include "scheduler/AdminHost.hpp" #include "scheduler/AdminUser.hpp" #include "scheduler/ArchivalRoute.hpp" @@ -29,7 +30,6 @@ #include "scheduler/Tape.hpp" #include "scheduler/TapePool.hpp" #include "scheduler/SecurityIdentity.hpp" -#include "scheduler/UserIdentity.hpp" #include "xroot_plugins/XrdProFile.hpp" #include "XrdSec/XrdSecEntity.hh"