#use strict;
############################################################
#
# David Wood (david@zepheira.com)
# January 2010
#
# Script to send PURLz v1.x batch loading XML files to a PURLz server.
#
# Copyright 2010 Zepheira LLC. Licensed under the Apache License,
# Version 2.0 (the "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
# or agreed to in writing, software distributed under the License is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.
#
###########################################################
###############################
# CHANGE THESE VARS AS NEEDED #
###############################
my $server = 'localhost:8080';
my $userid = 'userid';
my $passwd = 'password';
my $workurl = "http://$server/admin/purls";
my $cookiefile = 'lwpcookies.txt';
my $useoldfile = 0;
my $xml = "";
my $directory = "batch_files";
# set up user agent with a cookie jar
my $res;
my $req;
file => 'lwpcookies.txt',
autosave => 1,
ignore_discard => 1,
);
print STDERR "no old cookie jar file, so asking for new authorization\n"
if ($useoldfile && ! -e $cookiefile);
print STDERR "set up cookie jar\n";
unless ($useoldfile && -e $cookiefile) {
# try the authorization call, saving the cookie
referrer => '/docs/index.html',
]);
print STDERR "make auth request\n";
print STDERR "save cookie jar file\n";
$cookie_jar->save();
}
print STDERR "load cookie jar from the file\n";
$cookie_jar->load();
# Open log file.
# Make a new request for each file in the directory.
# Get content from file
local $/=undef;
binmode FILE;
close FILE;
# DBG
Content_Type => 'text/xml',
#print $response->error_as_HTML unless $response->is_success;
# Report results.
print "$file OK\n";
print LOG "$file OK\n";
} else {
print "\nERROR: $file: $report\n\n";
print LOG "\nERROR: $file: $report\n\n";
}
}
close(LOG);