#!/usr/local/bin/perl # # Management tool # # Ajoy K Ranga, # #----------------------------------------------------------------------- # # This tools provides the manager the list of buckets which are in the # temporary archive. Manager, after looking at the buckets can decide # what to do with the bucket. # #------------------------------------------------------------------------ # # ########################################################################## require "cgi-lib.pl"; print &PrintHeader; &ReadParse(*query); #Parse the query string &topPage(); #if this script is called without any arguments then provide the default #interface if($query{"interface"} eq '') { &authorizationInterface(); } #if value of interface field is 'showBuckets' call showBucketsInterface elsif($query{"interface"} eq 'showBuckets') { &showBucketsInterface(); } #if the value of the interface is 'send' call moveBuckets elsif( $query{"interface"} eq 'moveBucket' ) { &moveBuckets(); } ########################################################## # # # # Subroutine: topPage # creates the top portion of every interface # # # ########################################################## sub topPage { print < ODU Digital Library

Welcome to Digital Library Management Tools Home Page.


END } ############################################################## # # Subroutine: sockConnect # # Purpose: Connects to the index.cgi of the given bucket # if @_ = ("metadata", bucketHandle) , it will connect ot index.cgi # and gets the metadata of the bucket and from the that finds the # BUCKET_TITLE of the bucketHandle # if @_ = ("FinishCheck", bucketHandle), it will connect to index.cgi # and gets the state of the bucket # ################################################################ sub sockConnect { use Socket; # required for Socket stuff to work.... sub INTEL{0}; sub ATT{0}; sub dokill { kill 9,$child if $child; } local($method,$rootdir) = @_; $them = "dlib.cs.odu.edu"; $port= "8000"; $SIG{'INT'} = 'dokill'; $sockaddr = 'S n a4 x8'; chop($hostname = `hostname`); ($name, $aliases, $proto) = getprotobyname('tcp'); ($name, $aliases, $port) = getservbyname($port, 'tcp') unless $port =~ /^\d+$/; ($name, $aliases, $type, $len, $thisaddr) = gethostbyname($hostname); ($name, $aliases, $type, $len, $thataddr) = gethostbyname($them); $this = pack($sockaddr, &AF_INET, 0, $thisaddr); $that = pack($sockaddr, &AF_INET, $port, $thataddr); socket(S, &PF_INET, &SOCK_STREAM, $proto) || return(0); bind(S, $this) || return(0); connect(S, $that) || return(0); #S is name of socket select(S); $| = 1; select(STDOUT); if($method eq 'FinishCheck') { print S "GET /bucket/$rootdir/index.cgi?method=read_state&state=finish","\n\n"; while () { $line = $_; # print $line; if($line =~ /1/){ return 1; } } } elsif ($method eq 'metadata') { print S "GET /bucket/$rootdir/index.cgi?method=metadata","\n\n"; while() { $line = $_; if($line =~ /^TITLE::/){ ($tag,$BUCKET_TITLE) = split(/::/,$line); return; } } } return 0; } ################################################################################# # # Subroutine: moveBuckets # # Purpose: Move the approved buckets from TempArch to final Arhive # Delete the dissapproved buckets # Dont do anything with undecided buckets # Bucket Handles are embedded in the values of the fields named bucket1, bucket2, # etc. # ################################################################################## sub moveBuckets { local($index); local($NoOfBuckets) = $query{"NoOfBuckets"}; for($index=0; $index<$NoOfBuckets; $index++) { local($archive) = "archive".$index; local($archiveName) = $query{$archive}; local($bucketNo) = "bucket".$index; local($value) = $query{$bucketNo}; #get the value of the fields name bucket1, bucket2,etc local($flag,$bucketHandle) = split(/:/,$value); #if $flag = 1, then approve the above bucket if($flag eq '1') { if($archiveName eq 'Secure Archive') { #change by zhao, zhipeng in June 99 #`mv /home/dlibuser/TempArch/$bucketHandle/ /home/dlibuser/dienst/DocumentDB/ncstrlplus.odu.cs/$bucketHandle`; `mv /home/dlibuser/TempArch/$bucketHandle/ /home/dlibuser/public_html/ltrs/populate/output97/$bucketHandle`; } else { $bibfile=$bucketHandle.".bib"; open(BIB,">>/home/dlibuser/TempArch/$bucketHandle/_md.pkg/$bibfile"); print BIB "NCSTRLPLUS_URL:: http://dlib.cs.odu.edu:8000/finalarchive/$bucketHandle"; print BIB "\n"; close(BIB); #print "ajoy"; mkdir("/home/dlibuser/dienst/DocumentDB/ncstrlplus.odu.cs/$bucketHandle",0775); `cp /home/dlibuser/TempArch/$bucketHandle/_md.pkg/$bibfile /home/dlibuser/dienst/DocumentDB/ncstrlplus.odu.cs/$bucketHandle/$bibfile`; `mv /home/dlibuser/TempArch/$bucketHandle/ /home/dlibuser/public_archive/$bucketHandle`; } print "

$bucketHandle has been approved

"; } } } ####################################################################### # # Subroutine: showBucketsInterface # # Purpose: After the user submits the form for authorization, his validity # is cheked here (have to do this stuff later). If the # validity is o.k., then gets all the buckets in TempArch # and shows it to the user. # # # ######################################################################### sub showBucketsInterface { print < function formSubmit() { document.forms[0].submit(); } END #read the root dir of buckets in the temp. archive and place it in the list # @buckets. opendir(P,"/home/dlibuser/TempArch"); @buckets = grep(!/^\.\.?$/, readdir(P)); closedir(P); print 'Following is the list of buckets which are finished and waiting', " for approval"; print '
'; print ''; $index=0; print ""; print ""; print ""; print ""; print ""; print ""; #get all the finished buckets. foreach $bucketHandle (@buckets) { if(&sockConnect("FinishCheck",$bucketHandle)){ &sockConnect("metadata",$bucketHandle); #places the title bucket in $BUCKET_TITLE print ""; print "
Bucket TitleApproveDisapproveUndecidedMove to
"; print "","$index. ", $BUCKET_TITLE, "(",$bucketHandle,")",""; print ""; print ''; #send values as "name=bucket1, value = 1:TR-123". this means , if there are two #buckets in TempArch, then for the second bucket, the name for this field #will be bucket2. For each bucket there are three radio buttons. depending on button #the user selects , that value will be sent. that means if manager approves #bucket1 and dissaproves bucket2, then name=bucket1 and value=1:TR-123, #will be sent for 1st buckets and name=bucket2 and value=0:TR-124 will be #sent for the second bucket. print ""; print '', "
"; print "
"; print '', "
"; print "
"; print ''; print '
'; $index++; } } print "

"; print ''; print ''; print '

'; print ''; } ############################################################## # # Subroutine: authorizationInterface # Purpose: To Construct the interface for authorization # # INPUTFIELDS in the constructed forms # NAME VALUE # # interface showBuckets (hidden field with pre-set value) # user user enters the value # paswd user's password # # ###################################################################3 sub authorizationInterface { print < function validate() { var submit = true; if (document.forms[0].user.value.length == 0) { alert("User Name is required"); document.forms[0].user.focus(); document.forms[0].user.select(); submit = false; return; } if (document.forms[0].paswd.value.length == 0) { alert("Password is required"); document.forms[0].paswd.focus(); document.forms[0].paswd.select(); submit = false; return; } if(submit) { document.forms[0].submit(); } }
Name:
Password:


END }