Browse Source

- added validate() method to bag

master
parent
commit
62a2ad405a
9 changed files with 93 additions and 2 deletions
  1. +2
    -1
      src/include/bag.hpp
  2. +1
    -0
      src/include/bagmetadata.hpp
  3. +1
    -0
      src/include/manifest.hpp
  4. +3
    -1
      src/include/payload.hpp
  5. +5
    -0
      src/lib/bagmetadata.cpp
  6. +1
    -0
      src/lib/load_bag.cpp
  7. +5
    -0
      src/lib/manifest.cpp
  8. +5
    -0
      src/lib/payload.cpp
  9. +70
    -0
      src/lib/validate_bag.cpp

+ 2
- 1
src/include/bag.hpp View File

@ -22,10 +22,11 @@ class Bag {
string tag_file_character_encoding;
class Payload *payload_p;;
class Payloadmanifest *payloadmanifest_p;
// next elements are optional
class Tagmanifest *tagmanifest_p;
class Bagmetadata *bagmetadata_p;
class Fetchfile *fetchfile_p;
class Othertags *othertags_p; //TODO: optional
class Othertags *othertags_p;
public:
Bag();
Bag(string dfname);


+ 1
- 0
src/include/bagmetadata.hpp View File

@ -30,6 +30,7 @@ class Bagmetadata{
Bagmetadata( string basedir );
bool has_bagmetadata();
map<string,string> get_metadata();
bool validate();
};
#endif


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

@ -10,6 +10,7 @@ class Manifest{
map<checksum_algorithms,string> manifest_algorithm_files;
public:
virtual map<string,string> get_checksum_file_pairs(checksum_algorithms algorithm);
virtual bool validate();
};
#endif


+ 3
- 1
src/include/payload.hpp View File

@ -16,6 +16,8 @@ class Payload{
Payload( string basedir );
list<string> get_all_relative_paths();
list<string> get_all_absolute_paths();
bool validate();
};
#endif
// vim: set tabstop=4
// vim: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab

+ 5
- 0
src/lib/bagmetadata.cpp View File

@ -75,4 +75,9 @@ Bagmetadata::Bagmetadata( string basedir ) {
map <string,string> Bagmetadata::get_metadata() {
return this->metadata;
}
bool Bagmetadata::validate() {
// TODO
return true;
}
// vim: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab

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

@ -75,6 +75,7 @@ Bag::Bag( string dfname ) {
Bag::payloadmanifest_p->get_checksum_file_pairs( md5 );
Bag::tagmanifest_p->get_checksum_file_pairs( md5 );
cout << "The bag '"<<dfname<<"' is " << (this->validate() ? "valid" : "invalid") << endl;
}


+ 5
- 0
src/lib/manifest.cpp View File

@ -32,4 +32,9 @@ map<string,string> Manifest::get_checksum_file_pairs(checksum_algorithms alg) {
}
return checksum_file_pairs;
}
bool Manifest::validate() {
// TODO
return true;
}
// vim: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab

+ 5
- 0
src/lib/payload.cpp View File

@ -48,4 +48,9 @@ list<string> Payload::get_all_absolute_paths() {
}
return strpaths;
}
bool Payload::validate() {
// TODO
return true;
}
// vim: set tabstop=4

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

@ -0,0 +1,70 @@
#include "bag.hpp"
bool Bag::validate() {
bool is_valid = true;
if (this->bagit_version_major != 0) {
is_valid = false;
}
if (this->bagit_version_minor != 97) {
is_valid = false;
}
if (0 != tag_file_character_encoding.compare( "UTF-8" )) {
is_valid = false;
}
if (NULL == this->payload_p) {
is_valid = false;
} else {
bool ret = this->payload_p->validate();
if (ret == false) {
is_valid = false;
}
}
if (NULL == this->payloadmanifest_p) {
is_valid = false;
} else {
bool ret = this->payloadmanifest_p->validate();
if (ret == false) {
is_valid = false;
}
}
// next elements are optional
if (NULL == this->tagmanifest_p) {
} else {
bool ret = this->tagmanifest_p->validate();
if (ret == false) {
is_valid = false;
}
}
if (NULL == this->bagmetadata_p) {
} else {
bool ret = this->bagmetadata_p->validate();
if (ret == false) {
is_valid = false;
}
}
/*
if (NULL == this->fetchfile_p) {
} else {
bool ret = this->fetchfile_p->validate();
if (ret == false) {
is_valid = false;
}
}
if (NULL == this->othertags_p) {
} else {
bool ret = this->othertags_p->validate();
if (ret == false) {
is_valid = false;
}
}
*/
return is_valid;
}
// vim: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab

Loading…
Cancel
Save