|
Lines 48-54
to committing to the database.
Link Here
|
| 48 |
|
48 |
|
| 49 |
If the MARCXML cannot be parsed but can be recovered by stripping non-XML |
49 |
If the MARCXML cannot be parsed but can be recovered by stripping non-XML |
| 50 |
characters (C<StripNonXmlChars>), the stripped version is saved and |
50 |
characters (C<StripNonXmlChars>), the stripped version is saved and |
| 51 |
C<stripped_nonxml> is set on the object so callers can notify the user. |
51 |
C<nonxml_stripped> is persisted on the row so callers and the UI can notify the user. |
| 52 |
|
52 |
|
| 53 |
If the MARCXML cannot be recovered at all, a |
53 |
If the MARCXML cannot be recovered at all, a |
| 54 |
I<Koha::Exceptions::Metadata::Invalid> exception is thrown. |
54 |
I<Koha::Exceptions::Metadata::Invalid> exception is thrown. |
|
Lines 69-75
sub store {
Link Here
|
| 69 |
}; |
69 |
}; |
| 70 |
my $marcxml_error = $@; |
70 |
my $marcxml_error = $@; |
| 71 |
chomp $marcxml_error; |
71 |
chomp $marcxml_error; |
| 72 |
unless ($marcxml) { |
72 |
if ($marcxml) { |
|
|
73 |
|
| 74 |
# Clean parse – clear any previously recorded stripping |
| 75 |
$self->nonxml_stripped(undef); |
| 76 |
} else { |
| 73 |
|
77 |
|
| 74 |
# Attempt recovery by stripping non-XML characters |
78 |
# Attempt recovery by stripping non-XML characters |
| 75 |
my $stripped_metadata = StripNonXmlChars( $self->metadata ); |
79 |
my $stripped_metadata = StripNonXmlChars( $self->metadata ); |
|
Lines 85-91
sub store {
Link Here
|
| 85 |
) |
89 |
) |
| 86 |
); |
90 |
); |
| 87 |
$self->metadata($stripped_metadata); |
91 |
$self->metadata($stripped_metadata); |
| 88 |
$self->{_stripped_nonxml} = $marcxml_error; |
92 |
$self->nonxml_stripped($marcxml_error); |
| 89 |
} else { |
93 |
} else { |
| 90 |
|
94 |
|
| 91 |
# Truly unrecoverable |
95 |
# Truly unrecoverable |
|
Lines 104-125
sub store {
Link Here
|
| 104 |
return $self->SUPER::store; |
108 |
return $self->SUPER::store; |
| 105 |
} |
109 |
} |
| 106 |
|
110 |
|
| 107 |
=head3 stripped_nonxml |
|
|
| 108 |
|
| 109 |
if ( my $error = $metadata->stripped_nonxml ) { |
| 110 |
# warn user that non-XML characters were removed on last store() |
| 111 |
} |
| 112 |
|
| 113 |
Returns the original decode error string if non-XML characters were stripped |
| 114 |
during the most recent call to C<store()>, or C<undef> otherwise. |
| 115 |
|
| 116 |
=cut |
| 117 |
|
| 118 |
sub stripped_nonxml { |
| 119 |
my $self = shift; |
| 120 |
return $self->{_stripped_nonxml}; |
| 121 |
} |
| 122 |
|
| 123 |
=head3 record |
111 |
=head3 record |
| 124 |
|
112 |
|
| 125 |
my $record = $metadata->record; |
113 |
my $record = $metadata->record; |