Skip to content
Snippets Groups Projects
Commit 7ffc4c81 authored by Daniele Kruse's avatar Daniele Kruse
Browse files

Encapsulated fileds and did some changes to the ArchiveRequest

parent e3ce2815
No related branches found
No related tags found
No related merge requests found
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* 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.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "common/ArchiveRequest.hpp"
#include "exception/Exception.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::ArchiveRequest::ArchiveRequest() {
m_srcURLSet = false;
m_fileSizeSet = false;
m_checksumTypeSet = false;
m_checksumValueSet = false;
m_storageClassSet = false;
m_drInstanceSet = false;
m_drPathSet = false;
m_drOwnerSet = false;
m_drGroupSet = false;
m_drBlobSet = false;
}
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
cta::ArchiveRequest::~ArchiveRequest() throw() {
}
//------------------------------------------------------------------------------
// allFieldsSet
//------------------------------------------------------------------------------
bool cta::ArchiveRequest::allFieldsSet() const {
if(m_srcURLSet==true
&& m_fileSizeSet==true
&& m_checksumTypeSet==true
&& m_checksumValueSet==true
&& m_storageClassSet==true
&& m_drInstanceSet==true
&& m_drPathSet==true
&& m_drOwnerSet==true
&& m_drGroupSet==true
&& m_drBlobSet==true) {
return true;
}
return false;
}
//------------------------------------------------------------------------------
// setDrBlob
//------------------------------------------------------------------------------
void cta::ArchiveRequest::setDrBlob(std::string drBlob) {
m_drBlob = drBlob;
m_drBlobSet = true;
}
//------------------------------------------------------------------------------
// getDrBlob
//------------------------------------------------------------------------------
std::string cta::ArchiveRequest::getDrBlob() const {
if(!allFieldsSet()) {
throw cta::exception::Exception(std::string(__FUNCTION__)+" Error: not all fields of the ArchiveRequest have been set!");
}
return m_drBlob;
}
//------------------------------------------------------------------------------
// setDrGroup
//------------------------------------------------------------------------------
void cta::ArchiveRequest::setDrGroup(std::string drGroup) {
m_drGroup = drGroup;
m_drGroupSet = true;
}
//------------------------------------------------------------------------------
// getDrGroup
//------------------------------------------------------------------------------
std::string cta::ArchiveRequest::getDrGroup() const {
if(!allFieldsSet()) {
throw cta::exception::Exception(std::string(__FUNCTION__)+" Error: not all fields of the ArchiveRequest have been set!");
}
return m_drGroup;
}
//------------------------------------------------------------------------------
// setDrOwner
//------------------------------------------------------------------------------
void cta::ArchiveRequest::setDrOwner(std::string drOwner) {
m_drOwner = drOwner;
m_drOwnerSet = true;
}
//------------------------------------------------------------------------------
// getDrOwner
//------------------------------------------------------------------------------
std::string cta::ArchiveRequest::getDrOwner() const {
if(!allFieldsSet()) {
throw cta::exception::Exception(std::string(__FUNCTION__)+" Error: not all fields of the ArchiveRequest have been set!");
}
return m_drOwner;
}
//------------------------------------------------------------------------------
// setDrPath
//------------------------------------------------------------------------------
void cta::ArchiveRequest::setDrPath(std::string drPath) {
m_drPath = drPath;
m_drPathSet = true;
}
//------------------------------------------------------------------------------
// getDrPath
//------------------------------------------------------------------------------
std::string cta::ArchiveRequest::getDrPath() const {
if(!allFieldsSet()) {
throw cta::exception::Exception(std::string(__FUNCTION__)+" Error: not all fields of the ArchiveRequest have been set!");
}
return m_drPath;
}
//------------------------------------------------------------------------------
// setDrInstance
//------------------------------------------------------------------------------
void cta::ArchiveRequest::setDrInstance(std::string drInstance) {
m_drInstance = drInstance;
m_drInstanceSet = true;
}
//------------------------------------------------------------------------------
// getDrInstance
//------------------------------------------------------------------------------
std::string cta::ArchiveRequest::getDrInstance() const {
if(!allFieldsSet()) {
throw cta::exception::Exception(std::string(__FUNCTION__)+" Error: not all fields of the ArchiveRequest have been set!");
}
return m_drInstance;
}
//------------------------------------------------------------------------------
// setStorageClass
//------------------------------------------------------------------------------
void cta::ArchiveRequest::setStorageClass(std::string storageClass) {
m_storageClass = storageClass;
m_storageClassSet = true;
}
//------------------------------------------------------------------------------
// getStorageClass
//------------------------------------------------------------------------------
std::string cta::ArchiveRequest::getStorageClass() const {
if(!allFieldsSet()) {
throw cta::exception::Exception(std::string(__FUNCTION__)+" Error: not all fields of the ArchiveRequest have been set!");
}
return m_storageClass;
}
//------------------------------------------------------------------------------
// setChecksumValue
//------------------------------------------------------------------------------
void cta::ArchiveRequest::setChecksumValue(std::string checksumValue) {
m_checksumValue = checksumValue;
m_checksumValueSet = true;
}
//------------------------------------------------------------------------------
// getChecksumValue
//------------------------------------------------------------------------------
std::string cta::ArchiveRequest::getChecksumValue() const {
if(!allFieldsSet()) {
throw cta::exception::Exception(std::string(__FUNCTION__)+" Error: not all fields of the ArchiveRequest have been set!");
}
return m_checksumValue;
}
//------------------------------------------------------------------------------
// setChecksumType
//------------------------------------------------------------------------------
void cta::ArchiveRequest::setChecksumType(std::string checksumType) {
m_checksumType = checksumType;
m_checksumTypeSet = true;
}
//------------------------------------------------------------------------------
// getChecksumType
//------------------------------------------------------------------------------
std::string cta::ArchiveRequest::getChecksumType() const {
if(!allFieldsSet()) {
throw cta::exception::Exception(std::string(__FUNCTION__)+" Error: not all fields of the ArchiveRequest have been set!");
}
return m_checksumType;
}
//------------------------------------------------------------------------------
// setFileSize
//------------------------------------------------------------------------------
void cta::ArchiveRequest::setFileSize(uint64_t fileSize) {
m_fileSize = fileSize;
m_fileSizeSet = true;
}
//------------------------------------------------------------------------------
// getFileSize
//------------------------------------------------------------------------------
uint64_t cta::ArchiveRequest::getFileSize() const {
if(!allFieldsSet()) {
throw cta::exception::Exception(std::string(__FUNCTION__)+" Error: not all fields of the ArchiveRequest have been set!");
}
return m_fileSize;
}
//------------------------------------------------------------------------------
// setSrcURL
//------------------------------------------------------------------------------
void cta::ArchiveRequest::setSrcURL(std::string srcURL) {
m_srcURL = srcURL;
m_srcURLSet = true;
}
//------------------------------------------------------------------------------
// getSrcURL
//------------------------------------------------------------------------------
std::string cta::ArchiveRequest::getSrcURL() const {
if(!allFieldsSet()) {
throw cta::exception::Exception(std::string(__FUNCTION__)+" Error: not all fields of the ArchiveRequest have been set!");
}
return m_srcURL;
}
......@@ -21,44 +21,112 @@
#include <stdint.h>
#include <string>
#include "common/DRInfo.hpp"
namespace cta {
/**
* Structure to store an archive request.
*/
struct ArchiveRequest {
public:
/**
* Constructor
*/
ArchiveRequest();
/**
* Destructor
*/
~ArchiveRequest() throw();
void setDrBlob(std::string drBlob);
std::string getDrBlob() const;
void setDrGroup(std::string drGroup);
std::string getDrGroup() const;
void setDrOwner(std::string drOwner);
std::string getDrOwner() const;
void setDrPath(std::string drPath);
std::string getDrPath() const;
void setDrInstance(std::string drInstance);
std::string getDrInstance() const;
void setStorageClass(std::string storageClass);
std::string getStorageClass() const;
void setChecksumValue(std::string checksumValue);
std::string getChecksumValue() const;
void setChecksumType(std::string checksumType);
std::string getChecksumType() const;
void setFileSize(uint64_t fileSize);
uint64_t getFileSize() const;
void setSrcURL(std::string srcURL);
std::string getSrcURL() const;
private:
/**
* @return true if all fields have been set, false otherwise
*/
bool allFieldsSet() const;
/**
* The EOS src URL.
*/
std::string src_URL;
std::string m_srcURL;
bool m_srcURLSet;
/**
* The size of the file to be archived in bytes.
*/
uint64_t fileSize;
uint64_t m_fileSize;
bool m_fileSizeSet;
/**
* The checksum type.
*/
std::string checksumType;
std::string m_checksumType;
bool m_checksumTypeSet;
/**
* The checksum value.
*/
std::string checksumValue;
std::string m_checksumValue;
bool m_checksumValueSet;
/**
* The storage class name.
*/
std::string storageClass;
std::string m_storageClass;
bool m_storageClassSet;
/**
* The disaster recovery EOS instance.
*/
std::string m_drInstance;
bool m_drInstanceSet;
/**
* The disaster recovery EOS path.
*/
std::string m_drPath;
bool m_drPathSet;
/**
* The disaster recovery EOS owner.
*/
std::string m_drOwner;
bool m_drOwnerSet;
/**
* The disaster recovery EOS group.
*/
std::string m_drGroup;
bool m_drGroupSet;
/**
* The disaster recovery info
* The disaster recovery EOS key-value string containing everything above and more (no parsing by CTA).
*/
cta::DRInfo drInfo;
std::string m_drBlob;
bool m_drBlobSet;
}; // struct ArchiveRequest
......
......@@ -14,6 +14,7 @@ set (COMMON_LIB_SRC_FILES
archiveNS/StorageClass.cpp
archiveNS/Tape.cpp
archiveNS/TapeFileLocation.cpp
ArchiveRequest.cpp
CreationLog.cpp
checksum/Checksum.cpp
exception/Backtrace.cpp
......
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* 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.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
namespace cta {
/**
* Structure to store an archive request.
*/
struct DRInfo {
/**
* The EOS instance.
*/
std::string instance;
/**
* The EOS path.
*/
std::string path;
/**
* The EOS owner.
*/
std::string owner;
/**
* The EOS group.
*/
std::string group;
/**
* The EOS key-value string containing everything above and more (no parsing by CTA).
*/
std::string blob;
}; // struct DRInfo
} // namespace cta
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment