Skip to content

Commit 8d89a7d

Browse files
committed
Handle multiples errors in ADM implementation checker
Signed-off-by: Maxime Gervais <gervais.maxime@gmail.com>
1 parent 42b4a11 commit 8d89a7d

22 files changed

Lines changed: 2763 additions & 156 deletions

Source/Common/FileRegistered.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ class FileRegistered
2727
{
2828
public:
2929
FileRegistered() : analyze_percent(0), file_id(-1), policy(-1), display(-1), verbosity(-1), report_kind(0), mil_version(0),
30-
analyzed(false), implementation_valid(false), policy_valid(false), policy_has_info(false), policy_has_warning(false), create_policy(false), need_update(true)
30+
analyzed(false), implementation_valid(false), implementation_has_info(false), implementation_has_warning(false),
31+
policy_valid(false), policy_has_info(false), policy_has_warning(false), create_policy(false), need_update(true)
3132
{
3233
}
3334

@@ -45,6 +46,8 @@ class FileRegistered
4546
this->analyze_percent = f.analyze_percent;
4647
this->analyzed = f.analyzed;
4748
this->implementation_valid = f.implementation_valid;
49+
this->implementation_has_info = f.implementation_has_info;
50+
this->implementation_has_warning = f.implementation_has_warning;
4851
this->policy_valid = f.policy_valid;
4952
this->policy_has_info = f.policy_has_info;
5053
this->policy_has_warning = f.policy_has_warning;
@@ -82,6 +85,8 @@ class FileRegistered
8285
unsigned int index;
8386
bool analyzed;
8487
bool implementation_valid;
88+
bool implementation_has_info;
89+
bool implementation_has_warning;
8590
bool policy_valid;
8691
bool policy_has_info;
8792
bool policy_has_warning;

Source/Common/Reports.cpp

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ int Reports::checker_validate(int user, MediaConchLib::report report, const std:
155155
{
156156
//XXX
157157
std::string report;
158-
if (get_implementation_report(user, files[i], options, report, res->valid, err) < 0)
158+
if (get_implementation_report(user, files[i], options, report, res->valid, res->has_info, res->has_warning, err) < 0)
159159
return -1;
160160
}
161161
else if (report == MediaConchLib::report_MediaVeraPdf)
@@ -268,7 +268,9 @@ int Reports::get_reports_output(int user, const std::vector<long>& files,
268268
std::string tmp;
269269
std::string err;
270270
bool is_valid = false;
271-
if (get_implementation_reports(user, files, options, tmp, is_valid, err) < 0)
271+
bool has_info = false;
272+
bool has_warning = false;
273+
if (get_implementation_reports(user, files, options, tmp, is_valid, has_info, has_warning, err) < 0)
272274
tmp = std::string();
273275

274276
if (f == MediaConchLib::format_Html)
@@ -286,6 +288,13 @@ int Reports::get_reports_output(int user, const std::vector<long>& files,
286288

287289
if (!result->has_valid)
288290
result->has_valid = true;
291+
292+
if (!result->has_info)
293+
result->has_info = has_info;
294+
295+
if (!result->has_warning)
296+
result->has_warning = has_warning;
297+
289298
if (!is_valid)
290299
result->valid = false;
291300

@@ -466,10 +475,12 @@ int Reports::get_reports_output_JStree(int user, const std::vector<long>& files,
466475
//---------------------------------------------------------------------------
467476
int Reports::get_implementation_reports(int user, const std::vector<long>& files,
468477
const std::map<std::string, std::string>& options,
469-
std::string& report, bool& valid, std::string& err)
478+
std::string& report, bool& valid, bool& has_info, bool& has_warning, std::string& err)
470479
{
471480
bool AcceptsHttps = core->accepts_https();
472481
valid = true;
482+
has_info = false;
483+
has_warning = false;
473484

474485
std::stringstream verbo;
475486
std::map<std::string, std::string>::const_iterator it = options.find("verbosity");
@@ -495,7 +506,9 @@ int Reports::get_implementation_reports(int user, const std::vector<long>& files
495506
report += " <media ref=\"" + file + "\">";
496507
std::string implem;
497508
bool v = false;
498-
if (get_implementation_report(user, files[i], options, implem, v, err) < 0)
509+
bool info = false;
510+
bool warn = false;
511+
if (get_implementation_report(user, files[i], options, implem, v, info, warn, err) < 0)
499512
implem = std::string();
500513
else
501514
get_content_of_media_in_xml(implem);
@@ -504,6 +517,9 @@ int Reports::get_implementation_reports(int user, const std::vector<long>& files
504517

505518
if (!v)
506519
valid = false;
520+
521+
has_info |= info;
522+
has_warning |= warn;
507523
}
508524

509525
report += "</MediaConch>\n";
@@ -513,10 +529,12 @@ int Reports::get_implementation_reports(int user, const std::vector<long>& files
513529

514530
//---------------------------------------------------------------------------
515531
int Reports::get_implementation_report(int user, long file, const std::map<std::string, std::string>& options,
516-
std::string& report, bool& valid, std::string& err)
532+
std::string& report, bool& valid, bool& has_info, bool& has_warning, std::string& err)
517533
{
518534
std::string options_str = Core::serialize_string_from_options_map(options);
519535
valid = true;
536+
has_info = false;
537+
has_warning = false;
520538
std::string tmp_report;
521539

522540
bool registered = false;
@@ -544,7 +562,10 @@ int Reports::get_implementation_report(int user, long file, const std::map<std::
544562
return -1;
545563

546564
if (valid)
565+
{
547566
valid = implementation_is_valid(tmp_report);
567+
implementation_has_info_or_warning(tmp_report, has_info, has_warning);
568+
}
548569
report += tmp_report;
549570

550571
return 0;
@@ -846,7 +867,9 @@ int Reports::create_report_ma_xml(int user, const std::vector<long>& files,
846867
{
847868
std::string implem;
848869
bool valid;
849-
if (get_implementation_report(user, files[i], options, implem, valid, err) < 0)
870+
bool info;
871+
bool warning;
872+
if (get_implementation_report(user, files[i], options, implem, valid, info, warning, err) < 0)
850873
implem = std::string();
851874
else
852875
get_content_of_media_in_xml(implem);
@@ -983,6 +1006,33 @@ bool Reports::implementation_is_valid(const std::string& report)
9831006
return true;
9841007
}
9851008

1009+
//---------------------------------------------------------------------------
1010+
bool Reports::implementation_has_info_or_warning(const std::string& report, bool& has_info, bool& has_warning)
1011+
{
1012+
has_info=false;
1013+
has_warning=false;
1014+
1015+
size_t pos=0;
1016+
std::string search(" outcome=\"");
1017+
while ((pos = report.find(search, pos)) != std::string::npos)
1018+
{
1019+
if (pos + search.size() + 4 < report.size())
1020+
{
1021+
if (report[pos + search.size()] == 'i' && report[pos + search.size() + 1] == 'n' && report[pos + search.size() + 2] == 'f' && report[pos + search.size() + 3] == 'o')
1022+
has_info = true;
1023+
else if (report[pos + search.size()] == 'w' && report[pos + search.size() + 1] == 'a' && report[pos + search.size() + 2] == 'r' && report[pos + search.size() + 3] == 'n')
1024+
has_warning = true;
1025+
1026+
if (has_info && has_warning)
1027+
break;
1028+
}
1029+
1030+
pos += search.size();
1031+
}
1032+
1033+
return has_info || has_warning;
1034+
}
1035+
9861036
//---------------------------------------------------------------------------
9871037
bool Reports::policy_is_valid(const std::string& report)
9881038
{
@@ -1012,7 +1062,6 @@ bool Reports::policy_has_info_or_warning(const std::string& report, bool& has_in
10121062
has_info=false;
10131063
has_warning=false;
10141064

1015-
10161065
size_t pos=0;
10171066
std::string search(" outcome=\"");
10181067
while ((pos = report.find(search, pos)) != std::string::npos)

Source/Common/Reports.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ class Reports
7878
std::string& report, std::string& err);
7979
int get_implementation_reports(int user, const std::vector<long>& files,
8080
const std::map<std::string, std::string>& options,
81-
std::string& report, bool& valid, std::string& err);
81+
std::string& report, bool& valid, bool& has_info, bool& has_warning, std::string& err);
8282
int get_implementation_report(int user, long file, const std::map<std::string, std::string>& options,
83-
std::string& report, bool& valid, std::string& err);
83+
std::string& report, bool& valid, bool& has_info, bool& has_warning, std::string& err);
8484
int get_verapdf_report(int user, long file, std::string& report, bool& valid, std::string& err);
8585
int get_dpfmanager_report(int user, long file, std::string& report, bool& valid, std::string& err);
8686
int get_imsc1validation_report(int user, long file, std::string& report, bool& valid, std::string& err);
@@ -96,6 +96,7 @@ class Reports
9696

9797
// Reports validity
9898
bool implementation_is_valid(const std::string& report);
99+
bool implementation_has_info_or_warning(const std::string& report, bool& has_info, bool& has_warning);
99100
bool policy_is_valid(const std::string& report);
100101
bool policy_has_info_or_warning(const std::string& report, bool& has_info, bool& has_warning);
101102
bool verapdf_report_is_valid(const std::string& report);

Source/Common/XsltPolicy.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,10 @@ int XsltPolicy::create_rule_from_media_track_child(xmlNodePtr node, const std::s
712712
|| name == "BitRate"
713713
|| name == "Delay"
714714
|| name == "Count"
715-
|| name == "CodecID_Url")
715+
|| name == "CodecID_Url"
716+
|| name == "Errors"
717+
|| name == "Warnings"
718+
|| name == "Infos")
716719
continue;
717720

718721
if(xmlChildElementCount(child))

Source/Common/generated/ImplementationReportDisplayCSVXsl.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,14 @@ const char implementation_report_display_csv_xsl[] = {
7878
,'\x0a'
7979
,'\x20','\x20','\x20','\x20','\x20','\x20','\x20','\x20','\x3c','\x78','\x73','\x6c','\x3a','\x63','\x68','\x6f','\x6f','\x73','\x65','\x3e','\x0d'
8080
,'\x0a'
81-
,'\x20','\x20','\x20','\x20','\x20','\x20','\x20','\x20','\x20','\x20','\x3c','\x78','\x73','\x6c','\x3a','\x77','\x68','\x65','\x6e','\x20','\x74','\x65','\x73','\x74','\x3d','\x22','\x40','\x66','\x61','\x69','\x6c','\x5f','\x63','\x6f','\x75','\x6e','\x74','\x20','\x3d','\x20','\x27','\x30','\x27','\x22','\x3e','\x70','\x61','\x73','\x73','\x3c','\x2f','\x78','\x73','\x6c','\x3a','\x77','\x68','\x65','\x6e','\x3e','\x0d'
82-
,'\x0a'
8381
,'\x20','\x20','\x20','\x20','\x20','\x20','\x20','\x20','\x20','\x20','\x3c','\x78','\x73','\x6c','\x3a','\x77','\x68','\x65','\x6e','\x20','\x74','\x65','\x73','\x74','\x3d','\x22','\x40','\x66','\x61','\x69','\x6c','\x5f','\x63','\x6f','\x75','\x6e','\x74','\x20','\x3e','\x20','\x27','\x30','\x27','\x22','\x3e','\x66','\x61','\x69','\x6c','\x3c','\x2f','\x78','\x73','\x6c','\x3a','\x77','\x68','\x65','\x6e','\x3e','\x0d'
8482
,'\x0a'
83+
,'\x20','\x20','\x20','\x20','\x20','\x20','\x20','\x20','\x20','\x20','\x3c','\x78','\x73','\x6c','\x3a','\x77','\x68','\x65','\x6e','\x20','\x74','\x65','\x73','\x74','\x3d','\x22','\x40','\x77','\x61','\x72','\x6e','\x5f','\x63','\x6f','\x75','\x6e','\x74','\x20','\x3e','\x20','\x27','\x30','\x27','\x22','\x3e','\x77','\x61','\x72','\x6e','\x3c','\x2f','\x78','\x73','\x6c','\x3a','\x77','\x68','\x65','\x6e','\x3e','\x0d'
84+
,'\x0a'
85+
,'\x20','\x20','\x20','\x20','\x20','\x20','\x20','\x20','\x20','\x20','\x3c','\x78','\x73','\x6c','\x3a','\x77','\x68','\x65','\x6e','\x20','\x74','\x65','\x73','\x74','\x3d','\x22','\x40','\x69','\x6e','\x66','\x6f','\x5f','\x63','\x6f','\x75','\x6e','\x74','\x20','\x3e','\x20','\x27','\x30','\x27','\x22','\x3e','\x69','\x6e','\x66','\x6f','\x3c','\x2f','\x78','\x73','\x6c','\x3a','\x77','\x68','\x65','\x6e','\x3e','\x0d'
86+
,'\x0a'
87+
,'\x20','\x20','\x20','\x20','\x20','\x20','\x20','\x20','\x20','\x20','\x3c','\x78','\x73','\x6c','\x3a','\x6f','\x74','\x68','\x65','\x72','\x77','\x69','\x73','\x65','\x3e','\x70','\x61','\x73','\x73','\x3c','\x2f','\x78','\x73','\x6c','\x3a','\x6f','\x74','\x68','\x65','\x72','\x77','\x69','\x73','\x65','\x3e','\x0d'
88+
,'\x0a'
8589
,'\x20','\x20','\x20','\x20','\x20','\x20','\x20','\x20','\x3c','\x2f','\x78','\x73','\x6c','\x3a','\x63','\x68','\x6f','\x6f','\x73','\x65','\x3e','\x0d'
8690
,'\x0a'
8791
,'\x20','\x20','\x20','\x20','\x20','\x20','\x3c','\x2f','\x78','\x73','\x6c','\x3a','\x66','\x6f','\x72','\x2d','\x65','\x61','\x63','\x68','\x3e','\x0d'

0 commit comments

Comments
 (0)