@ -4,25 +4,25 @@
# include <sstream>
bool Bag : : validate ( stringstream & log ) {
bool Bag : : validate ( ) {
bool is_valid = true ;
if ( this - > bagit_version_major ! = 0 ) {
log < < " Bagit major version 0 is expected, but got: " < < to_string ( this - > bagit_version_major ) < < endl ;
this - > log < < " Bagit major version 0 is expected, but got: " < < to_string ( this - > bagit_version_major ) < < endl ;
is_valid = false ;
}
if ( this - > bagit_version_minor ! = 97 ) {
log < < " Bagit minor version 97 is expected, but got: " < < to_string ( this - > bagit_version_minor ) < < endl ;
this - > log < < " Bagit minor version 97 is expected, but got: " < < to_string ( this - > bagit_version_minor ) < < endl ;
is_valid = false ;
}
if ( 0 ! = tag_file_character_encoding . compare ( " UTF-8 " ) ) {
log < < " Bagit character encoding UTF-8 is expected, but got: " < < this - > tag_file_character_encoding < < endl ;
this - > log < < " Bagit character encoding UTF-8 is expected, but got: " < < this - > tag_file_character_encoding < < endl ;
is_valid = false ;
}
if ( NULL = = this - > payload_p ) {
log < < " Bagit payload directory 'data/' is expected, but could not found " < < endl ;
this - > log < < " Bagit payload directory 'data/' is expected, but could not found " < < endl ;
is_valid = false ;
} else {
bool ret = this - > payload_p - > validate ( log ) ;
bool ret = this - > payload_p - > validate ( ) ;
if ( ret = = false ) {
is_valid = false ;
}
@ -31,8 +31,8 @@ bool Bag::validate( stringstream & log ) {
is_valid = false ;
} else {
// checksums check
log < < " Bagit payload manifest " < < endl ;
bool ret = this - > payloadmanifest_p - > validate ( log ) ;
this - > log < < " Bagit payload manifest " < < endl ;
bool ret = this - > payloadmanifest_p - > validate ( ) ;
if ( ret = = false ) {
is_valid = false ;
}
@ -62,7 +62,7 @@ bool Bag::validate( stringstream & log ) {
int cmp_res = ( * it1 ) . compare ( * it2 ) ;
//cout << "COMP: "<<cmp_res<<" file='"<< (*it1) << "' checksummed file='" << (*it2) << "'" << endl;
if ( cmp_res < 0 ) {
log < < " Bagit warning, file ' " < < ( * it1 ) < < " ' in payload has no checksum entry in payload manifest " < < endl ;
this - > log < < " Bagit warning, file ' " < < ( * it1 ) < < " ' in payload has no checksum entry in payload manifest " < < endl ;
it1 + + ;
} else if ( cmp_res > 0 ) {
it2 + + ;
@ -76,15 +76,15 @@ bool Bag::validate( stringstream & log ) {
// next elements are optional
if ( NULL = = this - > tagmanifest_p ) {
} else {
log < < " Bagit tag manifest " < < endl ;
bool ret = this - > tagmanifest_p - > validate ( log ) ;
this - > log < < " Bagit tag manifest " < < endl ;
bool ret = this - > tagmanifest_p - > validate ( ) ;
if ( ret = = false ) {
is_valid = false ;
}
}
if ( NULL = = this - > bagmetadata_p ) {
} else {
bool ret = this - > bagmetadata_p - > validate ( log ) ;
bool ret = this - > bagmetadata_p - > validate ( ) ;
if ( ret = = false ) {
is_valid = false ;
}
@ -95,11 +95,11 @@ bool Bag::validate( stringstream & log ) {
oxum_t expected_oxum = this - > bagmetadata_p - > get_oxum ( ) ;
oxum_t calculated_oxum = c . oxum_of_filelist ( files ) ;
if ( expected_oxum . octetcount ! = calculated_oxum . octetcount ) {
log < < " Bagit payload oxum octectcount= " < < to_string ( expected_oxum . octetcount ) < < " expected, but " < < to_string ( calculated_oxum . octetcount ) < < " found " < < endl ;
this - > log < < " Bagit payload oxum octectcount= " < < to_string ( expected_oxum . octetcount ) < < " expected, but " < < to_string ( calculated_oxum . octetcount ) < < " found " < < endl ;
is_valid = false ;
}
if ( expected_oxum . streamcount ! = calculated_oxum . streamcount ) {
log < < " Bagit payload oxum streamcount= " < < to_string ( expected_oxum . streamcount ) < < " expected, but " < < to_string ( calculated_oxum . streamcount ) < < " found " < < endl ;
this - > log < < " Bagit payload oxum streamcount= " < < to_string ( expected_oxum . streamcount ) < < " expected, but " < < to_string ( calculated_oxum . streamcount ) < < " found " < < endl ;
is_valid = false ;
}