#!/usr/bin/perl -w
#-----------------------------------------------------------------
# ValidateService
# Author: Edward Kawas
# Copyright (c) 2007 Edward Kawas. All Rights Reserved.
#
# This module is free software; you can redistribute it and/or modify
# it under the same terms as Perl itself.
#
# This software is provided "as is" without warranty of any kind.
#
# $Id: AgentRDFValidator,v 1.1 2008/02/21 00:21:27 kawas Exp $
#
# This script is a web based form for testing the RDF agent
# on a specified user URL. When the script is called without
# parameters, a FORM is generated.
#
# Parameters understood by this script:
# url - the remote url of the RDF doc that the agent will fetch
# NOTES:
# 1. This script assumes that a BioMOBY registry is properly
# installed
# 2. JAVA_HOME is set in the environment or 'java' called
# at a command prompt actually calls a java runtime.
# 3. This script attempts to ensure that the arguement passed
# in is a 'real' url by first calling head on the URL.
# I am not sure if this will cause problems later on.
#-----------------------------------------------------------------
use strict;
use CGI qw/:standard/;
use LWP::UserAgent;
use HTTP::Request::Common;
use LWP::Simple qw(!head);
use MOBY::Config;
my $form = new CGI;
use Data::Dumper;
my $url = param('url') || undef;
if ($url) {
print $form->header('text/plain');
# confirm valid url
if (!LWP::Simple::head($url)) {
my $ua = LWP::UserAgent->new;
my $response = $ua->request(GET, $url);
print $response->content;
print "Invalid URL please try again.";
exit(0);
}
# call the agent
my $JAVA_HOME = $ENV{JAVA_HOME} || "";
if ($JAVA_HOME) {
$JAVA_HOME .="/bin/java";
} else {
$JAVA_HOME ="java";
}
my $CONF = MOBY::Config->new;
my $agent = $CONF->{mobycentral}->{rdfagent} or do{print "There was a problem calling the agent.\nPlease notify the administrator for this registry."; exit(0);};
my $text = `$JAVA_HOME -DRDFagent.home=$agent -jar $agent/RDFagent.jar -test $url`;
print $text;
} else {
print $form->header('text/html');
print generate_page();
}
sub generate_page {
return <
RDF Agent Test Page
RDF Agent Test Page
Please enter the url to your RDF document that describes
one or more moby services. The agent will then attempt to
resolve and parse that url.
Once the agent is complete, you should see what services were
considered valid and what errors occurred below.