[MOBY-guts] biomoby commit
Eddie Kawas
kawas at dev.open-bio.org
Thu Nov 29 19:59:51 UTC 2007
kawas
Thu Nov 29 14:59:51 EST 2007
Update of /home/repository/moby/moby-live/Perl/scripts
In directory dev.open-bio.org:/tmp/cvs-serv32005/Perl/scripts
Modified Files:
RESOURCES
Log Message:
added service instance caching to the script
moby-live/Perl/scripts RESOURCES,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/scripts/RESOURCES,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Perl/scripts/RESOURCES 2007/08/14 23:28:36 1.1
+++ /home/repository/moby/moby-live/Perl/scripts/RESOURCES 2007/11/29 19:59:51 1.2
@@ -1,61 +1,105 @@
-#!/usr/bin/perl -w
-#-----------------------------------------------------------------
-# RESOURCES
-# Author: Edward Kawas <edward.kawas at gmail.com>,
-# For copyright and disclaimer see below.
-#
-# $Id$
-#-----------------------------------------------------------------
-
-# this is a 're-port' of the RESOURCES script from java back to perl
-
-use strict;
-use CGI qw/:standard/;
-use MOBY::RDF::Ontologies::Objects;
-use MOBY::RDF::Ontologies::ServiceTypes;
-use MOBY::RDF::Ontologies::Namespaces;
-use MOBY::RDF::Ontologies::Services;
-
-
-my $url = url(-relative=>1, -path_info=>1);
-
-my $form = new CGI;
-
-if ($url =~ m/^RESOURCES\/MOBY\-S\/Objects$/) {
-
- my $x = MOBY::RDF::Ontologies::Objects->new;
- $x = $x->createAll();
- print $form->header('text/xml'), $x if $x;
- return;
-} elsif ($url =~ m/^RESOURCES\/MOBY\-S\/Services$/) {
- my $x = MOBY::RDF::Ontologies::ServiceTypes->new;
- $x = $x->createAll();
- print $form->header('text/xml'), $x if $x;
- return;
-} elsif ($url =~ m/^RESOURCES\/MOBY\-S\/ServiceInstances$/) {
- my $x = MOBY::RDF::Ontologies::Services->new;
- $x = $x->findService();
- print $form->header('text/xml'), $x if $x;
- return;
-} elsif ($url =~ m/^RESOURCES\/MOBY\-S\/Namespaces$/) {
- my $x = MOBY::RDF::Ontologies::Namespaces->new;
- $x = $x->createAll();
- print $form->header('text/xml'), $x if $x;
- return;
-} elsif ($url =~ m/^RESOURCES\/MOBY\-S\/FULL$/) {
- print $form->header('text/html');
- $form->start_html(-title=>'unavailable',);
- print h2("not","implemented");
- print end_html;
-} elsif ($url =~ m/^RESOURCES\/MOBY\-S\/ServiceDescription$/) {
- print $form->header('text/html');
- $form->start_html(-title=>'unavailable',);
- print h2("not","implemented");
- print end_html;
-} else {
- print $form->header('text/html');
- $form->start_html(-title=>'not MOBY-S',);
- print h2("not","MOBY-S");
- print end_html;
-}
-
+#!/usr/bin/perl -w
+#-----------------------------------------------------------------
+# RESOURCES
+# Author: Edward Kawas <edward.kawas at gmail.com>,
+# For copyright and disclaimer see below.
+#
+# $Id$
+#
+# NOTES:
+# 1. This script assumes that a BioMOBY registry is properly
+# installed and that SetEnv commands have been added to
+# the servers environment (e.g. httpd.conf)
+#
+# 2. Caching is enabled by default and can be toggled by
+# modifying $useCache [0=> disbled, 1=> enabled]
+# Caching really speeds up RDF generation and is highly
+# recomended
+#
+# 3. Caching requires that a cache dir be specified and
+# that the directory is readable by the web server
+# process. By default, the cache dir is set to '/tmp/'
+#-----------------------------------------------------------------
+
+# this is a 're-port' of the RESOURCES script from java back to perl
+
+use strict;
+use CGI qw/:standard/;
+use MOBY::RDF::Ontologies::Objects;
+use MOBY::RDF::Ontologies::ServiceTypes;
+use MOBY::RDF::Ontologies::Namespaces;
+use MOBY::RDF::Ontologies::Services;
+use MOBY::RDF::Ontologies::Cache::ServiceCache;
+
+# your cache dir
+my $dir = "/tmp/";
+
+# should we use caching?
+my $useCache = 1;
+
+my $url = url( -relative => 1, -path_info => 1 );
+
+my $form = new CGI;
+
+if ( $url =~ m/^RESOURCES\/MOBY\-S\/Objects$/ ) {
+
+ my $x = MOBY::RDF::Ontologies::Objects->new;
+ $x = $x->createAll();
+ print $form->header('text/xml'), $x if $x;
+
+} elsif ( $url =~ m/^RESOURCES\/MOBY\-S\/Services$/ ) {
+ my $x = MOBY::RDF::Ontologies::ServiceTypes->new;
+ $x = $x->createAll();
+ print $form->header('text/xml'), $x if $x;
+
+} elsif ( $url =~ m/^RESOURCES\/MOBY\-S\/ServiceInstances$/ ) {
+ my $x;
+ # shall we use the cache?
+ if ($useCache) {
+ $x =
+ MOBY::RDF::Ontologies::Cache::ServiceCache->new( cache => "$dir", );
+ $x = $x->get_rdf();
+
+ } else {
+ # no cache
+ $x = MOBY::RDF::Ontologies::Services->new;
+ $x = $x->findService();
+
+ }
+ # output the RDF generated
+ print $form->header('text/xml'), $x if $x;
+ # say not implemented if an error occurs
+ do {
+ print $form->header('text/html');
+ $form->start_html( -title => 'unavailable', );
+ print h2( "not", "implemented" );
+ print end_html;
+ } unless $x;
+
+} elsif ( $url =~ m/^RESOURCES\/MOBY\-S\/Namespaces$/ ) {
+
+ my $x = MOBY::RDF::Ontologies::Namespaces->new;
+ $x = $x->createAll();
+ print $form->header('text/xml'), $x if $x;
+
+} elsif ( $url =~ m/^RESOURCES\/MOBY\-S\/FULL$/ ) {
+
+ print $form->header('text/html');
+ $form->start_html( -title => 'unavailable', );
+ print h2( "not", "implemented" );
+ print end_html;
+
+} elsif ( $url =~ m/^RESOURCES\/MOBY\-S\/ServiceDescription$/ ) {
+ print $form->header('text/html');
+ $form->start_html( -title => 'unavailable', );
+ print h2( "not", "implemented" );
+ print end_html;
+
+} else {
+
+ print $form->header('text/html');
+ $form->start_html( -title => 'not MOBY-S', );
+ print h2( "not", "MOBY-S" );
+ print end_html;
+}
+
More information about the MOBY-guts
mailing list