1 # Copyright Tamil s.a.r.l. 2008-2015
2 # Copyright Biblibre 2008-2015
3 # Copyright The National Library of Finland, University of Helsinki 2016-2017
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
21 package Koha
::OAI
::Server
::ResumptionToken
;
26 use base
("HTTP::OAI::ResumptionToken");
29 # Extends HTTP::OAI::ResumptionToken
30 # A token is identified by:
38 my ($class, %args) = @_;
40 my $self = $class->SUPER::new
(%args);
42 my ($metadata_prefix, $offset, $from, $until, $set, $deleted, $deleted_count);
43 if ( $args{ resumptionToken
} ) {
44 ($metadata_prefix, $offset, $from, $until, $set, $deleted, $deleted_count)
45 = split( '/', $args{resumptionToken
} );
48 $metadata_prefix = $args{ metadataPrefix
};
49 $from = $args{ from
} || '1970-01-01';
50 $until = $args{ until };
52 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = gmtime( time );
53 $until = sprintf( "%.4d-%.2d-%.2d", $year+1900, $mon+1,$mday );
55 #Add times to the arguments, when necessary, so they correctly match against the DB timestamps
56 $from .= 'T00:00:00Z' if length($from) == 10;
57 $until .= 'T23:59:59Z' if length($until) == 10;
58 $offset = $args{ offset
} || 0;
59 $set = $args{ set
} || '';
60 $deleted = defined $args{ deleted
} ?
$args{ deleted
} : 1;
61 $deleted_count = defined $args{ deleted_count
} ?
$args{ deleted_count
} : 0;
64 $self->{ metadata_prefix
} = $metadata_prefix;
65 $self->{ offset
} = $offset;
66 $self->{ from
} = $from;
67 $self->{ until } = $until;
68 $self->{ set
} = $set;
69 $self->{ from_arg
} = _strip_UTC_designators
($from);
70 $self->{ until_arg
} = _strip_UTC_designators
($until);
71 $self->{ deleted
} = $deleted;
72 $self->{ deleted_count
} = $deleted_count;
74 $self->resumptionToken(
75 join( '/', $metadata_prefix, $offset, $from, $until, $set, $deleted, $deleted_count ) );
76 $self->cursor( $offset );
81 sub _strip_UTC_designators
{
82 my ( $timestamp ) = @_;
83 $timestamp =~ s/T/ /g;