Browse Source

- renamed get_oxum() to get_PayloadOxum()

- renamed has_oxum() to has_PayloadOxum()
- renamed get_bagmetadata() to get_metadata()
- renamed has_bagmetadata() to has_metadata()
master
Andreas Romeyke 3 years ago
parent
commit
bfc0363949
  1. 4
      src/lib/bag.cpp
  2. 6
      src/lib/bagmetadata.cpp
  3. 14
      test/test_bagmetadata.cpp

4
src/lib/bag.cpp

@ -245,12 +245,12 @@ bool Bag::validate() {
if (!ret) {
is_valid = false;
}
if (this->bagmetadata_p->has_oxum()) {
if (this->bagmetadata_p->has_PayloadOxum()) {
// check oxum of payload
Checksum c;
if (this->payload_p != nullptr) {
list<string> files = this->payload_p->get_all_absolute_paths();
oxum_t expected_oxum = this->bagmetadata_p->get_oxum();
oxum_t expected_oxum = this->bagmetadata_p->get_PayloadOxum();
oxum_t calculated_oxum = c.oxum_of_filelist( files );
if (expected_oxum.octetcount != calculated_oxum.octetcount) {
this->log << "Bagit payload oxum octectcount=" << to_string(expected_oxum.octetcount) << " expected, but " << to_string(calculated_oxum.octetcount) << " found" << endl;

6
src/lib/bagmetadata.cpp

@ -81,7 +81,7 @@ Bagmetadata::Bagmetadata( string basedir ) {
}
bool Bagmetadata::has_bagmetadata() {
bool Bagmetadata::has_metadata() {
return this->exist_bagmetadata_file;
}
@ -94,7 +94,7 @@ bool Bagmetadata::validate() {
return is_valid;
}
bool Bagmetadata::has_oxum() {
bool Bagmetadata::has_PayloadOxum() {
map<string, string>::iterator it;
it = this->metadata.find("Payload-Oxum");
if (it != this->metadata.end()) {
@ -104,7 +104,7 @@ bool Bagmetadata::has_oxum() {
return false;
}
oxum_t Bagmetadata::get_oxum() {
oxum_t Bagmetadata::get_PayloadOxum() {
oxum_t oxum{};
oxum.octetcount=0;
oxum.streamcount=0;

14
test/test_bagmetadata.cpp

@ -53,17 +53,17 @@ bool check_get_metadata(string dir) {
bool check_has_metadata(string dir) {
Bagmetadata p( std::move(dir) );
return p.has_bagmetadata();
return p.has_metadata();
}
bool check_has_oxum(string dir) {
bool check_has_PayloadOxum(string dir) {
Bagmetadata p( std::move(dir) );
return p.has_oxum();
return p.has_PayloadOxum();
}
oxum_t check_get_oxum(string dir) {
oxum_t check_get_PayloadOxum(string dir) {
Bagmetadata p( std::move(dir) );
return p.get_oxum();
return p.get_PayloadOxum();
}
bool check_store( string dir_load_from, string dir_store_to ) {
@ -78,12 +78,12 @@ BOOST_AUTO_TEST_CASE(constructor3) {BOOST_TEST(check_constructor("/tmp/"));};
BOOST_AUTO_TEST_CASE(check_metadata_exists) {BOOST_TEST( check_has_metadata("../testbags/bag_minimal_ok/")); };
BOOST_AUTO_TEST_CASE(check_metadata) {BOOST_TEST( check_get_metadata("../testbags/bag_minimal_ok/")); };
BOOST_AUTO_TEST_CASE(check_oxum_exists) {BOOST_TEST( check_has_oxum("../testbags/bag_minimal_ok/")); };
BOOST_AUTO_TEST_CASE(check_oxum_exists) {BOOST_TEST( check_has_PayloadOxum("../testbags/bag_minimal_ok/")); };
BOOST_AUTO_TEST_CASE(check_oxum) {
oxum_t expected{};
expected.octetcount=38;
expected.streamcount=4;
oxum_t result = check_get_oxum("../testbags/bag_minimal_ok/");
oxum_t result = check_get_PayloadOxum("../testbags/bag_minimal_ok/");
BOOST_TEST( expected.octetcount == result.octetcount);
BOOST_TEST( expected.streamcount == result.streamcount);
};

Loading…
Cancel
Save