--- loncom/lonnet/perl/lonnet.pm 2005/03/01 00:22:59 1.601 +++ loncom/lonnet/perl/lonnet.pm 2005/03/02 22:26:36 1.602 @@ -1,7 +1,7 @@ # The LearningOnline Network # TCP networking package # -# $Id: lonnet.pm,v 1.601 2005/03/01 00:22:59 albertel Exp $ +# $Id: lonnet.pm,v 1.602 2005/03/02 22:26:36 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -994,27 +994,27 @@ sub subscribe { sub repcopy { my $filename=shift; $filename=~s/\/+/\//g; - if ($filename=~m|^/home/httpd/html/adm/|) { return OK; } - if ($filename=~m|^/home/httpd/html/lonUsers/|) { return OK; } + if ($filename=~m|^/home/httpd/html/adm/|) { return 'OK'; } + if ($filename=~m|^/home/httpd/html/lonUsers/|) { return 'OK'; } if ($filename=~m|^/home/httpd/html/userfiles/| or $filename=~m|^/*uploaded/|) { return &repcopy_userfile($filename); } $filename=~s/[\n\r]//g; my $transname="$filename.in.transfer"; - if ((-e $filename) || (-e $transname)) { return OK; } + if ((-e $filename) || (-e $transname)) { return 'OK'; } my $remoteurl=subscribe($filename); if ($remoteurl =~ /^con_lost by/) { &logthis("Subscribe returned $remoteurl: $filename"); - return HTTP_SERVICE_UNAVAILABLE; + return 'HTTP_SERVICE_UNAVAILABLE'; } elsif ($remoteurl eq 'not_found') { #&logthis("Subscribe returned not_found: $filename"); - return HTTP_NOT_FOUND; + return 'HTTP_NOT_FOUND'; } elsif ($remoteurl =~ /^rejected by/) { &logthis("Subscribe returned $remoteurl: $filename"); - return FORBIDDEN; + return 'FORBIDDEN'; } elsif ($remoteurl eq 'directory') { - return OK; + return 'OK'; } else { my $author=$filename; $author=~s/\/home\/httpd\/html\/res\/([^\/]*)\/([^\/]*).*/$1\/$2/; @@ -1025,7 +1025,7 @@ sub repcopy { my $path="/$parts[1]/$parts[2]/$parts[3]/$parts[4]"; if ($path ne "$perlvar{'lonDocRoot'}/res") { &logthis("Malconfiguration for replication: $filename"); - return HTTP_BAD_REQUEST; + return 'HTTP_BAD_REQUEST'; } my $count; for ($count=5;$count<$#parts;$count++) { @@ -1042,7 +1042,7 @@ sub repcopy { my $message=$response->status_line; &logthis("WARNING:" ." LWP get: $message: $filename"); - return HTTP_SERVICE_UNAVAILABLE; + return 'HTTP_SERVICE_UNAVAILABLE'; } else { if ($remoteurl!~/\.meta$/) { my $mrequest=new HTTP::Request('GET',$remoteurl.'.meta'); @@ -1054,7 +1054,7 @@ sub repcopy { } } rename($transname,$filename); - return OK; + return 'OK'; } } } @@ -5237,10 +5237,8 @@ sub getfile { sub repcopy_userfile { my ($file)=@_; - if ($file =~ m|^/*uploaded/|) { $file=&filelocation("",$file); } - if ($file =~ m|^/home/httpd/html/lonUsers/|) { return OK; } - + if ($file =~ m|^/home/httpd/html/lonUsers/|) { return 'OK'; } my ($cdom,$cnum,$filename) = ($file=~m|^\Q$perlvar{'lonDocRoot'}\E/+userfiles/+([^/]+)/+([^/]+)/+(.*)|); my ($info,$rtncode); @@ -5263,7 +5261,7 @@ sub repcopy_userfile { return -1; } if ($info < $fileinfo[9]) { - return OK; + return 'OK'; } $info = ''; $lwpresp = &getuploaded('GET',$uri,$cdom,$cnum,\$info,\$rtncode); @@ -5297,7 +5295,7 @@ sub repcopy_userfile { open(FILE,">$file"); print FILE $info; close(FILE); - return OK; + return 'OK'; } sub tokenwrapper { @@ -6117,8 +6115,8 @@ subscribe($fname) : subscribe to a resou repcopy($filename) : subscribes to the requested file, and attempts to replicate from the owning library server, Might return -HTTP_SERVICE_UNAVAILABLE, HTTP_NOT_FOUND, FORBIDDEN, OK, or -HTTP_BAD_REQUEST, also attempts to grab the metadata for the +'HTTP_SERVICE_UNAVAILABLE', 'HTTP_NOT_FOUND', 'FORBIDDEN', 'OK', or +'HTTP_BAD_REQUEST', also attempts to grab the metadata for the resource. Expects the local filesystem pathname (/home/httpd/html/res/....)