+package C4::OAI::Description;
+
+use strict;
+use warnings;
+use HTTP::OAI;
+use HTTP::OAI::SAXHandler qw/ :SAX /;
+
+sub new {
+ my ( $class, %args ) = @_;
+
+ my $self = {};
+
+ if(my $setDescription = $args{setDescription}) {
+ $self->{setDescription} = $setDescription;
+ }
+ if(my $handler = $args{handler}) {
+ $self->{handler} = $handler;
+ }
+
+ bless $self, $class;
+ return $self;
+}
+
+sub set_handler {
+ my ( $self, $handler ) = @_;
+
+ $self->{handler} = $handler if $handler;
+
+ return $self;
+}
+
+sub generate {
+ my ( $self ) = @_;
+
+ g_data_element($self->{handler}, 'http://www.openarchives.org/OAI/2.0/', 'setDescription', {}, $self->{setDescription});
+
+ return $self;
+}
+
+# __END__ C4::OAI::Description
+
+package C4::OAI::ListSets;
+
+use strict;
+use warnings;
+use HTTP::OAI;
+use C4::OAI::Sets;
+
+use base ("HTTP::OAI::ListSets");
+
+sub new {
+ my ( $class, $repository, %args ) = @_;
+
+ my $self = HTTP::OAI::ListSets->new(%args);
+
+ my $token = C4::OAI::ResumptionToken->new(%args);
+ my $sets = GetOAISets;
+ my $pos = 0;
+ foreach my $set (@$sets) {
+ if ($pos < $token->{offset}) {
+ $pos++;
+ next;
+ }
+ my @descriptions;
+ foreach my $desc (@{$set->{'descriptions'}}) {
+ push @descriptions, C4::OAI::Description->new(
+ setDescription => $desc,
+ );
+ }
+ $self->set(
+ HTTP::OAI::Set->new(
+ setSpec => $set->{'spec'},
+ setName => $set->{'name'},
+ setDescription => \@descriptions,
+ )
+ );
+ $pos++;
+ last if ($pos + 1 - $token->{offset}) > $repository->{koha_max_count};
+ }