Browse Source

- added Payloadmanifest::validate()

- fixed some shadowing errors
master
parent
commit
4b4003f62c
6 changed files with 26 additions and 4 deletions
  1. +1
    -1
      src/include/manifest.hpp
  2. +4
    -0
      src/include/payloadmanifest.hpp
  3. +2
    -0
      src/include/tagmanifest.hpp
  4. +16
    -3
      src/lib/payloadmanifest.cpp
  5. +2
    -0
      src/lib/tagmanifest.cpp
  6. +1
    -0
      src/lib/validate_bag.cpp

+ 1
- 1
src/include/manifest.hpp View File

@ -7,7 +7,7 @@
using namespace std;
class Manifest{
protected:
private:
string basedir;
map<checksum_algorithms,string> manifest_algorithm_files;
public:


+ 4
- 0
src/include/payloadmanifest.hpp View File

@ -8,8 +8,12 @@
using namespace std;
class Payloadmanifest : public Manifest {
private:
string basedir;
map<checksum_algorithms,string> manifest_algorithm_files;
public:
Payloadmanifest( string basedir );
bool validate(list<string> & log);
};
#endif


+ 2
- 0
src/include/tagmanifest.hpp View File

@ -10,6 +10,8 @@ using namespace std;
class Tagmanifest : public Manifest {
private:
bool exist_manifest_files;
string basedir;
map<checksum_algorithms,string> manifest_algorithm_files;
public:
Tagmanifest( string basedir );
bool has_tagmanifest();


+ 16
- 3
src/lib/payloadmanifest.cpp View File

@ -26,11 +26,24 @@ Payloadmanifest::Payloadmanifest( string basedir ) {
// cout << "is file: "<< fs::is_regular_file( s) << endl;
if (fs::is_regular_file( s)) {
Payloadmanifest::manifest_algorithm_files[it->first] = filename;
// debug
cout << "PAYLOADMANIFEST: alg="<< it->first << " => filename=" << it->second << endl;
cout << " alg="<< it->first << " => filename=" << Payloadmanifest::manifest_algorithm_files[it->first] << endl;
// debug
cout << "PAYLOADMANIFEST: alg="<< it->first << " => filename=" << it->second << endl;
// cout << " alg="<< it->first << " => filename=" << Payloadmanifest::manifest_algorithm_files[it->first] << endl;
}
}
}
bool Payloadmanifest::validate( list<string> & log ) {
bool is_valid = true;
bool tmp = Manifest::validate( log );
if (false == tmp) { is_valid = false; }
// check if at least one payload file exist
cout << "payload_manifest: " << this->manifest_algorithm_files.size() << endl;
if (0 == this->manifest_algorithm_files.size()) {
log.push_back("Bagit payloadmanifest count greater zero expected, but " + to_string(this->manifest_algorithm_files.size()) + " found");
is_valid = false;
}
return is_valid;
}
// vim: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab

+ 2
- 0
src/lib/tagmanifest.cpp View File

@ -28,6 +28,8 @@ Tagmanifest::Tagmanifest( string basedir ) {
cout << "is file: "<< fs::is_regular_file( s) << endl;
if (fs::is_regular_file( s)) {
Tagmanifest::manifest_algorithm_files[it->first] = filename;
// debug
cout << "TAGMANIFEST: alg="<< it->first << " => filename=" << it->second << endl;
}
}
this->exist_manifest_files = possible_manifest_files.empty();


+ 1
- 0
src/lib/validate_bag.cpp View File

@ -29,6 +29,7 @@ bool Bag::validate( list<string> & log ) {
if (NULL == this->payloadmanifest_p) {
is_valid = false;
} else {
// checksums check
log.push_back( "Bagit payload manifest");
bool ret = this->payloadmanifest_p->validate( log );
if (ret == false) {


Loading…
Cancel
Save