1 package Koha::Biblio::Metadata;
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 3 of the License, or (at your option) any later
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along
15 # with Koha; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 use Koha::Exceptions::Metadata;
26 use base qw(Koha::Object);
30 Koha::Metadata - Koha Metadata Object class
40 my $record = $metadata->record;
42 Returns an object representing the metadata record. The expected record type
43 corresponds to this table:
45 -------------------------------
46 | format | object type |
47 -------------------------------
48 | marcxml | MARC::Record |
49 -------------------------------
55 =item If an unsupported format is found, it throws a I<Koha::Exceptions::Metadata> exception.
57 =item If it fails to create the record object, it throws a I<Koha::Exceptions::Metadata::Invalid> exception.
69 if ( $self->format eq 'marcxml' ) {
70 $record = eval { MARC::Record::new_from_xml( $self->metadata, 'utf-8', $self->schema ); };
71 my $marcxml_error = $@;
74 Koha::Exceptions::Metadata::Invalid->throw(
76 format => $self->format,
77 schema => $self->schema,
78 decoding_error => $marcxml_error,
83 Koha::Exceptions::Metadata->throw(
84 'Koha::Biblio::Metadata->record called on unhandled format: ' . $self->format );
90 =head2 Internal methods
97 return 'BiblioMetadata';