6 use Data::Dump qw(dump);
9 =begin eprints configuration
11 add to /usr/share/eprints3/archives/grf/cfg/cfg.d/user_roles.pl
13 $c->{user_roles}->{admin} = [qw{
22 our $repo = "http://eprints.ffzg.hr/grf";
27 warn "# repo: $repo [$user]\n";
31 my $ua = LWP::UserAgent->new;
32 $ua->credentials("eprints.ffzg.hr:80", "EPrintsREST", "admin", "grfadmin");
35 my $response = $ua->get( "$repo/rest/eprint/" );
36 if ($response->is_success) {
37 my $html = $response->decoded_content;
39 @ids = grep { defined $_ } map { m{href=['"](\d+)/} && $1 || undef } split(/[\n\r]/, $html);
41 die $response->status_line;
44 print "ids = ",dump(@ids),$/;
50 $response = $ua->get( "$repo/rest/eprint/$nr.xml" );
52 if ($response->is_success) {
53 print "ORIG\n", $response->decoded_content;
55 die "ERROR: ", $response->status_line;
59 my $xml = $response->decoded_content; # or whatever
60 my $title = $1 if $xml =~ m{<title>(.+)</title>};
61 $title =~ s{\s*\[editirano]}{} or $title .= ' [editirano]';
62 my $update = $ua->request( HTTP::Request->new( 'PUT', "$repo/rest/eprint/$nr/title.txt", undef, "$title" ) );
63 if ($update->is_success) {
64 print "UPDATE: ", $update->decoded_content;
66 die "ERROR: ", $update->status_line;
71 $xml =~ s{(eprint.*)$old}{$1$nr}g;
73 my $create = $ua->request( HTTP::Request->new( 'PUT', "$repo/rest/eprint/$nr/", [ 'Content-type' => 'text/xml' ], utf8::decode($xml) ) );
74 if ($create->is_success) {
75 print "CREATE: ", $create->decoded_content;
77 die "ERROR: ", $create->status_line, $create->decoded_content;