MOBY

 view release on metacpan or  search on metacpan

share/cgi/AgentRDFValidator  view on Meta::CPAN

#
# 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 <<EOF;
<TD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<style type="text/css">
body { background: #ffffcd;
       color: #000000;
       font-family: Arial, Helvetica, sans-serif;
       font-size: 12pt;
       font-weight: normal;
       margin-top: 10px;
       margin-right: 1em;
       margin-bottom: 1em;
       margin-left: 1em;
       background-position: left top;
       background-repeat: no-repeat;
     }

h1 { border: solid; 
     text-align:center;
     background-color:yellow;
     color: navy;
   }
h2 { border: ridge;
     padding: 5px;
     background-color:yellow;
     color: navy;
   }
h3 { border: none;
     padding: 5px;
     background-color:yellow;
     color: navy;
   }
iframe {
	width:95%;
	frameborder:0;
	height:70%;
	scrolling:auto;
	}
</style>
<title>RDF Agent Test Page</title>
</head>
<body>
<script>
<!--
if( !window.XMLHttpRequest ) XMLHttpRequest = function(){
        try{ return new ActiveXObject("MSXML3.XMLHTTP") }catch(e){}
        try{ return new ActiveXObject("MSXML2.XMLHTTP.3.0") }catch(e){}
        try{ return new ActiveXObject("Msxml2.XMLHTTP") }catch(e){}
        try{ return new ActiveXObject("Microsoft.XMLHTTP") }catch(e){}
        throw new Error("Could not find an XMLHttpRequest alternative.")
};

function modular_waiting(vis, msg, options) {
// Pass true to show the dialogue screen, false to hide
var options   = options || {};
var zindex   = options.zindex || 1000;
var height   = options.height || 25;
var width   = options.width || 35;
var opacity   = options.opacity || 90;



( run in 0.479 second using v1.01-cache-2.11-cpan-bbe5e583499 )