Commit 7a1a334d authored by Steven Murray's avatar Steven Murray
Browse files

WIP

parent 3ae96a87
#include "ArchiveJob.hpp"
#include "ArchivalJob.hpp"
//------------------------------------------------------------------------------
// JobStateToStr
//------------------------------------------------------------------------------
const char *cta::ArchiveJob::JobStateToStr(const JobState enumValue) throw() {
const char *cta::ArchivalJob::JobStateToStr(const JobState enumValue) throw() {
switch(enumValue) {
case JOBSTATE_NONE : return "NONE";
case JOBSTATE_PENDING: return "PENDING";
......@@ -16,7 +16,7 @@ const char *cta::ArchiveJob::JobStateToStr(const JobState enumValue) throw() {
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::ArchiveJob::ArchiveJob():
cta::ArchivalJob::ArchivalJob():
m_state(JOBSTATE_NONE),
m_totalNbFileTransfers(0),
m_nbFailedFileTransfers(0),
......@@ -26,7 +26,7 @@ cta::ArchiveJob::ArchiveJob():
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::ArchiveJob::ArchiveJob(
cta::ArchivalJob::ArchivalJob(
const std::string &id,
const JobState state,
const uint32_t totalNbFileTransfers,
......@@ -44,42 +44,42 @@ cta::ArchiveJob::ArchiveJob(
//------------------------------------------------------------------------------
// getId
//------------------------------------------------------------------------------
const std::string &cta::ArchiveJob::getId() const throw() {
const std::string &cta::ArchivalJob::getId() const throw() {
return m_id;
}
//------------------------------------------------------------------------------
// getState
//------------------------------------------------------------------------------
cta::ArchiveJob::JobState cta::ArchiveJob::getState() const throw() {
cta::ArchivalJob::JobState cta::ArchivalJob::getState() const throw() {
return m_state;
}
//------------------------------------------------------------------------------
// getTotalNbFileTransfers
//------------------------------------------------------------------------------
uint32_t cta::ArchiveJob::getTotalNbFileTransfers() const throw() {
uint32_t cta::ArchivalJob::getTotalNbFileTransfers() const throw() {
return m_totalNbFileTransfers;
}
//------------------------------------------------------------------------------
// getNbFailedFileTransfers
//------------------------------------------------------------------------------
uint32_t cta::ArchiveJob::getNbFailedFileTransfers() const throw() {
uint32_t cta::ArchivalJob::getNbFailedFileTransfers() const throw() {
return m_nbFailedFileTransfers;
}
//------------------------------------------------------------------------------
// getCreationTime
//------------------------------------------------------------------------------
time_t cta::ArchiveJob::getCreationTime() const throw() {
time_t cta::ArchivalJob::getCreationTime() const throw() {
return m_creationTime;
}
//------------------------------------------------------------------------------
// getCreator
//------------------------------------------------------------------------------
const cta::UserIdentity &cta::ArchiveJob::getCreator()
const cta::UserIdentity &cta::ArchivalJob::getCreator()
const throw() {
return m_creator;
}
......@@ -87,6 +87,6 @@ const cta::UserIdentity &cta::ArchiveJob::getCreator()
//------------------------------------------------------------------------------
// getComment
//------------------------------------------------------------------------------
const std::string &cta::ArchiveJob::getComment() const throw() {
const std::string &cta::ArchivalJob::getComment() const throw() {
return m_comment;
}
......@@ -8,13 +8,13 @@
namespace cta {
/**
* Class representing a archive job.
* Class representing an archival job.
*/
class ArchiveJob {
class ArchivalJob {
public:
/**
* Enumeration of the possible states of an archive job.
* Enumeration of the possible states of an archival job.
*/
enum JobState {
JOBSTATE_NONE,
......@@ -34,19 +34,19 @@ public:
/**
* Constructor.
*/
ArchiveJob();
ArchivalJob();
/**
* Constructor.
*
* @param id The identification string of the archive job.
* @param state The state of the archive job.
* @param id The identification string of the archival job.
* @param state The state of the archival job.
* @param totalNbFileTransfers The total number of file transfers
* represented by the archive job.
* @param creator The identity of the user that created the archive job.
* @param comment The comment describing the archive job.
* represented by the archival job.
* @param creator The identity of the user that created the archival job.
* @param comment The comment describing the archival job.
*/
ArchiveJob(
ArchivalJob(
const std::string &id,
const JobState state,
const uint32_t totalNbFileTransfers,
......@@ -54,23 +54,23 @@ public:
const std::string &comment);
/**
* Returns the identification string of the archive job.
* Returns the identification string of the archival job.
*
* @return The identification string of the archive job.
* @return The identification string of the archival job.
*/
const std::string &getId() const throw();
/**
* Returns the state of the archive job.
* Returns the state of the archival job.
*
* @return The state of the archive job.
* @return The state of the archival job.
*/
JobState getState() const throw();
/**
* Returns the total number of file transfers represented by the archive job.
* Returns the total number of file transfers represented by the archival job.
*
* @return The total number of file transfers represented by the archive job.
* @return The total number of file transfers represented by the archival job.
*/
uint32_t getTotalNbFileTransfers() const throw();
......@@ -82,40 +82,40 @@ public:
uint32_t getNbFailedFileTransfers() const throw();
/**
* Returns the time when the archive job was created.
* Returns the time when the archival job was created.
*
* @return The time when the archive job was created.
* @return The time when the archival job was created.
*/
time_t getCreationTime() const throw();
/**
* Returns the identity of the user that created the archive job.
* Returns the identity of the user that created the archival job.
*
* @return The identity of the user that created the archive job.
* @return The identity of the user that created the archival job.
*/
const UserIdentity &getCreator() const throw();
/**
* Returns the comment describing the archive job.
* Returns the comment describing the archival job.
*
* @return The comment describing the archive job.
* @return The comment describing the archival job.
*/
const std::string &getComment() const throw();
private:
/**
* The identification string of the archive job.
* The identification string of the archival job.
*/
std::string m_id;
/**
* The state of the archive job.
* The state of the archival job.
*/
JobState m_state;
/**
* The total number of file transfers repesented by this archive job.
* The total number of file transfers repesented by this archival job.
*/
uint32_t m_totalNbFileTransfers;
......@@ -125,20 +125,20 @@ private:
uint32_t m_nbFailedFileTransfers;
/**
* The time when the archive job was created.
* The time when the archival job was created.
*/
time_t m_creationTime;
/**
* The identity of the user that created the archive job.
* The identity of the user that created the archival job.
*/
UserIdentity m_creator;
/**
* Comment describing the archive job.
* Comment describing the archival job.
*/
std::string m_comment;
}; // class ArchiveJob
}; // class ArchivalJob
} // namespace cta
......@@ -3,11 +3,13 @@ cmake_minimum_required (VERSION 2.6)
set (MIDDLE_TIER_LIB_SRC_FILES
AdminHost.cpp
AdminUser.cpp
ArchiveJob.cpp
ArchivalJob.cpp
DirectoryEntry.cpp
DirectoryIterator.cpp
Exception.cpp
FileArchivalJob.cpp
FileAttribute.cpp
FileRetrievalJob.cpp
FileSystemDirectoryEntry.cpp
FileSystemNode.cpp
FileSystemStorageClass.cpp
......
#include "FileArchivalJob.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::FileArchivalJob::FileArchivalJob():
m_creationTime(time(NULL)) {
}
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::FileArchivalJob::FileArchivalJob(
const std::string &srcUrl,
const std::string &dstPath,
const UserIdentity &creator):
m_srcUrl(srcUrl),
m_dstPath(dstPath),
m_creationTime(time(NULL)),
m_creator(creator) {
}
//------------------------------------------------------------------------------
// getSrcUrl
//------------------------------------------------------------------------------
const std::string &cta::FileArchivalJob::getSrcUrl() const throw() {
return m_srcUrl;
}
//------------------------------------------------------------------------------
// getDstPath
//------------------------------------------------------------------------------
const std::string &cta::FileArchivalJob::getDstPath() const throw() {
return m_dstPath;
}
//------------------------------------------------------------------------------
// getCreationTime
//------------------------------------------------------------------------------
time_t cta::FileArchivalJob::getCreationTime() const throw() {
return m_creationTime;
}
//------------------------------------------------------------------------------
// getCreator
//------------------------------------------------------------------------------
const cta::UserIdentity &cta::FileArchivalJob::getCreator() const throw() {
return m_creator;
}
#pragma once
#include "UserIdentity.hpp"
#include <string>
#include <time.h>
namespace cta {
/**
* Class representing the job of archiving a file to tape.
*/
class FileArchivalJob {
public:
/**
* Constructor.
*/
FileArchivalJob();
/**
* Constructor.
*
* @param srcUrl The URL of the source file.
* @param dstPath The full path of the destination file within the archive.
* @param creator The identity of the user that created the job.
*/
FileArchivalJob(
const std::string &srcUrl,
const std::string &dstPath,
const UserIdentity &creator);
/**
* Returns the URL of the source file.
*
* @return The URL of the source file.
*/
const std::string &getSrcUrl() const throw();
/**
* Returns the full path of the destination file within the archive.
*
* @return The full path of the destination file within the archive.
*/
const std::string &getDstPath() const throw();
/**
* Returns the time when the job was created.
*
* @return The time when the job was created.
*/
time_t getCreationTime() const throw();
/**
* Returns the identity of the user that created the job.
*
* @return The identity of the user that created the job.
*/
const UserIdentity &getCreator() const throw();
private:
/**
* The URL of the source file.
*/
std::string m_srcUrl;
/**
* The full path of the destination file within the archive.
*/
std::string m_dstPath;
/**
* The time when the job was created.
*/
time_t m_creationTime;
/**
* The identity of the user that created the job.
*/
UserIdentity m_creator;
}; // class FileArchival
} // namespace cta
#include "FileRetrievalJob.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::FileRetrievalJob::FileRetrievalJob():
m_creationTime(time(NULL)) {
}
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::FileRetrievalJob::FileRetrievalJob(
const std::string &srcPath,
const std::string &dstUrl,
const UserIdentity &creator):
m_srcPath(srcPath),
m_dstUrl(dstUrl),
m_creationTime(time(NULL)),
m_creator(creator) {
}
//------------------------------------------------------------------------------
// getSrcPath
//------------------------------------------------------------------------------
const std::string &cta::FileRetrievalJob::getSrcPath() const throw() {
return m_srcPath;
}
//------------------------------------------------------------------------------
// getDstUrl
//------------------------------------------------------------------------------
const std::string &cta::FileRetrievalJob::getDstUrl() const throw() {
return m_dstUrl;
}
//------------------------------------------------------------------------------
// getCreationTime
//------------------------------------------------------------------------------
time_t cta::FileRetrievalJob::getCreationTime() const throw() {
return m_creationTime;
}
//------------------------------------------------------------------------------
// getCreator
//------------------------------------------------------------------------------
const cta::UserIdentity &cta::FileRetrievalJob::getCreator() const throw() {
return m_creator;
}
#pragma once
#include "UserIdentity.hpp"
#include <string>
#include <time.h>
namespace cta {
/**
* Class representing the job of retrieving a file from tape.
*/
class FileRetrievalJob {
public:
/**
* Constructor.
*/
FileRetrievalJob();
/**
* Constructor.
*
* @param srcPath The full path of the source file within the archive.
* @param dstUrl The URL of the destination file.
* @param creator The identity of the user that created the job.
*/
FileRetrievalJob(
const std::string &srcPath,
const std::string &dstUrl,
const UserIdentity &creator);
/**
* Returns the full path of the source file within the archive.
*
* @return The full path of the source file within the archive.
*/
const std::string &getSrcPath() const throw();
/**
* Returns the URL of the destination file.
*
* @return The URL of the destination file.
*/
const std::string &getDstUrl() const throw();
/**
* Returns the time when the job was created.
*
* @return The time when the job was created.
*/
time_t getCreationTime() const throw();
/**
* Returns the identity of the user that created the job.
*
* @return The identity of the user that created the job.
*/
const UserIdentity &getCreator() const throw();
private:
/**
* The full path of the source file within the archive.
*/
std::string m_srcPath;
/**
* The URL of the destination file.
*/
std::string m_dstUrl;
/**
* The time when the job was created.
*/
time_t m_creationTime;
/**
* The identity of the user that created the job.
*/
UserIdentity m_creator;
}; // class FileRetrieval
} // namespace cta
......@@ -2,7 +2,7 @@
#include "AdminHost.hpp"
#include "AdminUser.hpp"
#include "ArchiveJob.hpp"
#include "ArchivalJob.hpp"
#include "DirectoryIterator.hpp"
#include "LogicalLibrary.hpp"
#include "MigrationRoute.hpp"
......
#pragma once
#include "ArchiveJob.hpp"
#include "ArchivalJob.hpp"
#include "DirectoryIterator.hpp"
#include "FileArchivalJob.hpp"
#include "FileRetrievalJob.hpp"
#include "LogicalLibrary.hpp"
#include "MigrationRoute.hpp"
#include "SecurityIdentity.hpp"
......@@ -99,8 +101,8 @@ public:
const std::string &dirPath) const = 0;
/**
* Archives the specified list of source files to the specified destination
* within the archive namespace.
* Creates an archival job to asynchronously archive the specified source
* files to the specified destination within the archive.
*
* If there is more than one source file then the destination must be a
* directory.
......@@ -114,7 +116,7 @@ public:
* @param requester The identity of the user requesting the archival.
* @param srcUrls List of one or more source files.
* @param dst Destination file or directory within the archive namespace.
* @return The string identifier of the archive job.
* @return The string identifier of the archival job.
*/
virtual std::string archive(
const SecurityIdentity &requester,
......@@ -122,18 +124,61 @@ public:
const std::string &dst) = 0;
/**
* Gets the current list of archive jobs associated with the specified device
* group.
* Gets the list of archival jobs associated with the specified tape pool.
*
* @param requester The identity of the user requesting the list.
* @param tapePoolName The name of the tape pool.
* @return The list of jobs sorted by creation time in ascending order
* (oldest first).
*/
virtual std::list<ArchiveJob> getArchiveJobs(
virtual std::list<ArchivalJob> getArchivalJobs(
const SecurityIdentity &requester,
const std::string &tapePoolName) = 0;
/**
* Returns the individual file archival jobs associated with the specified
* archive job.
*
* @param requester The identity of the user requesting the list.
* @param archiveJobId The string identifer of the archive job.
* @return The individual file archival jobs.
*/
virtual std::list<FileArchivalJob> getFileArchivalJobs(
const SecurityIdentity &requester,
const std::string &archiveJobId) = 0;
/**
* Creates a retrieval job to asynchronously retrieve the specified archived
* files and copy them to the specified destination URL.
*
* If there is more than one archived file then the destination must be a
* directory.
*
* If there is only one archived file then the destination can be either a
* file or a directory.
*
* @param requester The identity of the user requesting the retrieval.
* @param srcPaths The list of one of more archived files.
* @param dstUrl The URL of the destination file or directory.
* @return The string identifier of the retrieval job.
*/
virtual std::string retrieve(
const SecurityIdentity &requester,
const std::list<std::string> &srcPaths,
const std::string &dstUrl) = 0;
/**
* Gets the individual file retrieval jobs associated with the specified
* retrieval job.
*
* @param requester The identity of the user requesting the list.
* @param retrievalJobId The string identifer of the retrieval job.
* @return The list of individual file retrieval jobs.
*/
virtual std::list<FileRetrievalJob> getFileRetrievalJobs(
const SecurityIdentity &requester,
const std::string &vretrievalJobId) = 0;
}; // class MiddleTierUser
} // namespace cta
......@@ -274,11 +274,41 @@ void cta::MockMiddleTierUser::checkUserIsAuthorisedToArchive(