Revision 3473
Added by walbridge over 17 years ago
register-dataset.cgi | ||
---|---|---|
177 | 177 |
$nceas_db_password = $config->nceas_db_password(); |
178 | 178 |
} |
179 | 179 |
my $debug = $config->debug(); |
180 |
if ($FORM::debug) { |
|
181 |
$debug = $FORM::debug; |
|
182 |
} |
|
180 | 183 |
my $lat = $config->get('lat'); |
181 | 184 |
my $lon = $config->get('lon'); |
182 | 185 |
|
... | ... | |
196 | 199 |
my $ttConfig = { |
197 | 200 |
INCLUDE_PATH => $templatesdir, |
198 | 201 |
INTERPOLATE => 0, |
199 |
POST_CHOMP => 1, |
|
202 |
POST_CHOMP => 1, |
|
203 |
#DEBUG => 'all', |
|
200 | 204 |
}; |
201 | 205 |
|
202 | 206 |
# create an instance of the template processor |
... | ... | |
226 | 230 |
if (!hasContent($metacatUrl)) { |
227 | 231 |
debug("Registry: No Metacat."); |
228 | 232 |
print "Content-type: text/html\n\n"; |
229 |
$$templateVars{'message'} = 'Error: Metacat is not initialized! Make sure' .
|
|
233 |
'Registry Error: Metacat is not initialized! Make sure' .
|
|
230 | 234 |
' MetacatUrl is set correctly in ' . $FORM::cfg . '.cfg'; |
231 |
$template->process( $loginFormTemplate, $templateVars); |
|
232 | 235 |
exit(0); |
233 | 236 |
} |
234 | 237 |
|
... | ... | |
573 | 576 |
} else { |
574 | 577 |
$$templateVars{'docid'} = $docid; |
575 | 578 |
$$templateVars{'cfg'} = $FORM::cfg; |
579 |
# delete the remaining file objects from disk |
|
580 |
for (my $fileNum = 0; $fileNum <= $FORM::upCount; $fileNum++) { |
|
581 |
my $fn = 'uploadname_' . $fileNum; |
|
582 |
if (hasContent(param($fn))) { |
|
583 |
deleteFile(param($fn)); |
|
584 |
} |
|
585 |
} |
|
586 |
|
|
576 | 587 |
} |
577 | 588 |
|
578 | 589 |
#if (! $error) { |
... | ... | |
750 | 761 |
#} |
751 | 762 |
} |
752 | 763 |
|
753 |
if (hasContent($FORM::beginningYear) && !($FORM::beginningYear =~ /[0-9][0-9][0-9][0-9]/)){
|
|
764 |
if (hasContent($FORM::beginningYear) && !($FORM::beginningYear =~ /[0-9]{4}/)){
|
|
754 | 765 |
push(@invalidParams, "Invalid year of start date specified.") |
755 | 766 |
} |
756 | 767 |
|
757 |
if (hasContent($FORM::endingYear) && !($FORM::endingYear =~ /[0-9][0-9][0-9][0-9]/)){
|
|
768 |
if (hasContent($FORM::endingYear) && !($FORM::endingYear =~ /[0-9]{4}/)){
|
|
758 | 769 |
push(@invalidParams, "Invalid year of stop date specified.") |
759 | 770 |
} |
760 | 771 |
|
... | ... | |
1141 | 1152 |
return ($outputName, $digest); |
1142 | 1153 |
} |
1143 | 1154 |
|
1155 |
sub deleteFile { |
|
1156 |
my $input = shift; |
|
1157 |
my $fileName = $tmpdir . "/" . $input; |
|
1158 |
|
|
1159 |
if (-e $fileName) { |
|
1160 |
unlink $fileName or |
|
1161 |
debug("Registry: failed to delete file $fileName."); |
|
1162 |
} else { |
|
1163 |
debug("Registry: unable to find file $fileName"); |
|
1164 |
} |
|
1165 |
if (!-e $fileName) { |
|
1166 |
debug("Registry: successfully deleted $fileName"); |
|
1167 |
} |
|
1168 |
} |
|
1169 |
|
|
1144 | 1170 |
sub uploadData { |
1145 | 1171 |
my $data = shift; |
1146 | 1172 |
my $docid = shift; |
... | ... | |
1240 | 1266 |
foreach my $origName (param()) { |
1241 | 1267 |
my $origNum = $origName; |
1242 | 1268 |
$origNum =~ s/origNamelast//; # get the index of the parameter 0 to 10 |
1243 |
if ( $origNum =~ /^([0-9])$/) { |
|
1269 |
if ( $origNum =~ /^([0-9]+)$/) {
|
|
1244 | 1270 |
# do not generate EML for empty originator fields |
1245 | 1271 |
if (hasContent(param("origNamefirst" . $origNum))) { |
1246 | 1272 |
my $first = normalize(param("origNamefirst" . $origNum)); |
... | ... | |
1355 | 1381 |
foreach my $kwName (param()) { |
1356 | 1382 |
my $kwNum = $kwName; |
1357 | 1383 |
$kwNum =~ s/keyword//; # get the index of the parameter 0, ..., 10 |
1358 |
if ( $kwNum =~ /^([0-9])$/ ){ |
|
1384 |
if ( $kwNum =~ /^([0-9]+)$/ ){
|
|
1359 | 1385 |
# don't generate xml for empty keyword fields |
1360 | 1386 |
# don't generate taxonomic keyword fields, those go in taxonomic coverage |
1361 | 1387 |
if (hasContent(param($kwName))) { |
... | ... | |
1538 | 1564 |
|
1539 | 1565 |
if (hasContent($FORM::origDeliveryContact) || |
1540 | 1566 |
hasContent($FORM::origCityContact) || |
1541 |
(hasContent($FORM::origStateContact) && |
|
1542 |
($FORM::origStateContact !~ "Select state here.")) || |
|
1567 |
hasContent($FORM::origStateContact) || |
|
1543 | 1568 |
hasContent($FORM::origStateOtherContact) || |
1544 | 1569 |
hasContent($FORM::origZIPContact) || |
1545 | 1570 |
hasContent($FORM::origCountryContact)) { |
... | ... | |
1552 | 1577 |
$cont .= "<city>".normalize($FORM::origCityContact)."</city>\n"; |
1553 | 1578 |
} |
1554 | 1579 |
if (hasContent($FORM::origStateContact) && |
1555 |
($FORM::origStateContact !~ "Select state here.")) {
|
|
1580 |
($FORM::origStateContact !=~ /select state/i)) {
|
|
1556 | 1581 |
$cont .= "<administrativeArea>".normalize($FORM::origStateContact); |
1557 | 1582 |
$cont .= "</administrativeArea>\n"; |
1558 | 1583 |
} elsif (hasContent($FORM::origStateOtherContact)) { |
... | ... | |
1740 | 1765 |
my $taxIndex = $trn; |
1741 | 1766 |
$taxIndex =~ s/taxonRankName//; # get the index of the parameter 0, ..., 10 |
1742 | 1767 |
my $trv = "taxonRankValue".$taxIndex; |
1743 |
if ( $taxIndex =~ /[0-9]/ ){ |
|
1768 |
if ( $taxIndex =~ /[0-9]+/ ){
|
|
1744 | 1769 |
if (hasContent(param($trn)) && hasContent(param($trv))) { |
1745 | 1770 |
if (! $foundFirstTaxon) { |
1746 | 1771 |
$cov .= "<taxonomicCoverage>\n"; |
... | ... | |
3654 | 3679 |
} |
3655 | 3680 |
} |
3656 | 3681 |
|
3657 |
|
|
3658 | 3682 |
$$templateVars{'providerGivenName'} = normalizeCD($FORM::providerGivenName); |
3659 | 3683 |
$$templateVars{'providerSurName'} = normalizeCD($FORM::providerSurName); |
3660 | 3684 |
if($FORM::site eq "Select your station here."){ |
... | ... | |
3670 | 3694 |
$$templateVars{'origNamefirst0'} = normalizeCD($FORM::origNamefirst0); |
3671 | 3695 |
$$templateVars{'origNamelast0'} = normalizeCD($FORM::origNamelast0); |
3672 | 3696 |
$$templateVars{'origNameOrg'} = normalizeCD($FORM::origNameOrg); |
3673 |
# $$templateVars{'origRole0'} = $FORM::origRole0; |
|
3674 | 3697 |
$$templateVars{'origDelivery'} = normalizeCD($FORM::origDelivery); |
3675 | 3698 |
$$templateVars{'origCity'} = normalizeCD($FORM::origCity); |
3676 |
if($FORM::origState eq "Select State Here."){
|
|
3699 |
if ($FORM::origState =~ /select state/i) {
|
|
3677 | 3700 |
$$templateVars{'origState'} = ""; |
3678 |
}else{
|
|
3701 |
} else {
|
|
3679 | 3702 |
$$templateVars{'origState'} = $FORM::origState; |
3680 | 3703 |
} |
3681 | 3704 |
$$templateVars{'origStateOther'} = normalizeCD($FORM::origStateOther); |
... | ... | |
3686 | 3709 |
$$templateVars{'origEmail'} = normalizeCD($FORM::origEmail); |
3687 | 3710 |
$$templateVars{'useOrigAddress'} = normalizeCD($FORM::useOrigAddress); |
3688 | 3711 |
if($FORM::useOrigAddress eq "on"){ |
3712 |
|
|
3689 | 3713 |
$$templateVars{'origNamefirstContact'} = normalizeCD($FORM::origNamefirst0); |
3690 | 3714 |
$$templateVars{'origNamelastContact'} = normalizeCD($FORM::origNamelast0); |
3691 | 3715 |
$$templateVars{'origNameOrgContact'} = normalizeCD($FORM::origNameOrg); |
3692 | 3716 |
$$templateVars{'origDeliveryContact'} = normalizeCD($FORM::origDelivery); |
3693 | 3717 |
$$templateVars{'origCityContact'} = normalizeCD($FORM::origCity); |
3694 |
if($FORM::origState eq "Select State Here."){
|
|
3718 |
if($FORM::origState =~ /select state/i){
|
|
3695 | 3719 |
$$templateVars{'origStateContact'} = ""; |
3696 | 3720 |
}else{ |
3697 | 3721 |
$$templateVars{'origStateContact'} = $FORM::origState; |
... | ... | |
3708 | 3732 |
$$templateVars{'origNameOrgContact'} = normalizeCD($FORM::origNameOrgContact); |
3709 | 3733 |
$$templateVars{'origDeliveryContact'} = normalizeCD($FORM::origDeliveryContact); |
3710 | 3734 |
$$templateVars{'origCityContact'} = normalizeCD($FORM::origCityContact); |
3711 |
if($FORM::origStateContact eq "Select State Here."){
|
|
3735 |
if($FORM::origStateContact =~ /select state/i){
|
|
3712 | 3736 |
$$templateVars{'origStateContact'} = ""; |
3713 | 3737 |
}else{ |
3714 | 3738 |
$$templateVars{'origStateContact'} = $FORM::origStateContact; |
... | ... | |
3735 | 3759 |
$$templateVars{"origNamelast".$aoCount} = normalizeCD($aoLNArray->[$i]); |
3736 | 3760 |
$$templateVars{"origRole".$aoCount} = normalizeCD($aoRoleArray->[$i]); |
3737 | 3761 |
$aoCount++; |
3738 |
}
|
|
3762 |
}
|
|
3739 | 3763 |
} |
3740 | 3764 |
|
3741 | 3765 |
$$templateVars{'aoCount'} = $aoCount; |
... | ... | |
3811 | 3835 |
|
3812 | 3836 |
$$templateVars{'taxaCount'} = $taxonCount-1; |
3813 | 3837 |
$$templateVars{'taxaAuth'} = normalizeCD($FORM::taxaAuth); |
3814 |
|
|
3838 |
my $deleteCount = 0; |
|
3815 | 3839 |
for (my $upNum = 0; $upNum <= $FORM::upCount; $upNum++) { |
3816 | 3840 |
my $upn = "upload_$upNum"; |
3817 | 3841 |
if (hasContent(param($upn))) { |
3818 |
debug("Registry: processing existing file: $upn"); |
|
3819 |
$$templateVars{"upload_$upNum"} = param("upload_$upNum"); |
|
3820 |
$$templateVars{"uploadname_$upNum"} = param("uploadname_$upNum"); |
|
3821 |
$$templateVars{"uploadtype_$upNum"} = param("uploadtype_$upNum"); |
|
3842 |
if (grep {$_ eq ("uploadname_$upNum")} @FORM::deletefile) { |
|
3843 |
deleteFile(param("uploadname_$upNum")); |
|
3844 |
$deleteCount++; |
|
3845 |
} else { |
|
3846 |
debug("Registry: processing existing file: $upn"); |
|
3847 |
$$templateVars{"upload_$upNum"} = param("upload_$upNum"); |
|
3848 |
$$templateVars{"uploadname_$upNum"} = param("uploadname_$upNum"); |
|
3849 |
$$templateVars{"uploadtype_$upNum"} = param("uploadtype_$upNum"); |
|
3850 |
} |
|
3822 | 3851 |
} |
3823 | 3852 |
} |
3824 |
|
|
3853 |
|
|
3825 | 3854 |
my $uploadCount = 0; |
3826 | 3855 |
for (my $fileNum = 0; $fileNum <= $FORM::fileCount; $fileNum++) { |
3827 | 3856 |
my $fn = 'file_' . $fileNum; |
... | ... | |
3839 | 3868 |
$uploadCount++; |
3840 | 3869 |
} |
3841 | 3870 |
} |
3842 |
$$templateVars{'upCount'} = $uploadCount + $FORM::upCount; |
|
3871 |
# total uploads are: new uploads - deleted files + original uploads |
|
3872 |
$$templateVars{'upCount'} = $uploadCount - $deleteCount + $FORM::upCount; |
|
3843 | 3873 |
$$templateVars{'methodTitle'} = normalizeCD($FORM::methodTitle); |
3844 | 3874 |
|
3845 | 3875 |
my @tempMethodPara; |
... | ... | |
3934 | 3964 |
$$templateVars{'origNamefirst0'} = $FORM::origNamefirst0; |
3935 | 3965 |
$$templateVars{'origNamelast0'} = $FORM::origNamelast0; |
3936 | 3966 |
$$templateVars{'origNameOrg'} = $FORM::origNameOrg; |
3937 |
# $$templateVars{'origRole0'} = $FORM::origRole0; |
|
3938 | 3967 |
$$templateVars{'origDelivery'} = $FORM::origDelivery; |
3939 | 3968 |
$$templateVars{'origCity'} = $FORM::origCity; |
3940 | 3969 |
$$templateVars{'origState'} = $FORM::origState; |
... | ... | |
3969 | 3998 |
$origNameIndex =~ s/origNamefirst//; # get the index of the parameter 0, ..., 10 |
3970 | 3999 |
my $origNamelast = "origNamelast".$origNameIndex; |
3971 | 4000 |
my $origRole = "origRole".$origNameIndex; |
3972 |
if ( $origNameIndex =~ /[0-9]/ && $origNameIndex > 0){ |
|
4001 |
if ( $origNameIndex =~ /[0-9]+/ && $origNameIndex > 0){
|
|
3973 | 4002 |
if (hasContent(param($origName)) && hasContent(param($origNamelast)) && hasContent(param($origRole))) { |
3974 | 4003 |
debug("Registry processing keyword: $origName = ".param($origName)." $origNamelast = ".param($origNamelast)." $origRole = ".param($origRole)); |
3975 | 4004 |
$$templateVars{$origName} = normalizeCD(param($origName)); |
... | ... | |
3988 | 4017 |
$keyIndex =~ s/keyword//; # get the index of the parameter 0, ..., 10 |
3989 | 4018 |
my $keyType = "kwType".$keyIndex; |
3990 | 4019 |
my $keyTh = "kwTh".$keyIndex; |
3991 |
if ( $keyIndex =~ /[0-9]/ ){ |
|
4020 |
if ( $keyIndex =~ /[0-9]+/ ){
|
|
3992 | 4021 |
if (hasContent(param($kyd)) && hasContent(param($keyType)) && hasContent(param($keyTh))) { |
3993 | 4022 |
debug("Registry processing keyword: $kyd = ".param($kyd)." $keyType = ".param($keyType)." $keyTh = ".param($keyTh)); |
3994 | 4023 |
$$templateVars{$kyd} = param($kyd); |
... | ... | |
4040 | 4069 |
my $taxIndex = $trn; |
4041 | 4070 |
$taxIndex =~ s/taxonRankName//; # get the index of the parameter 0, ..., 10 |
4042 | 4071 |
my $trv = "taxonRankValue".$taxIndex; |
4043 |
if ( $taxIndex =~ /[0-9]/ ){ |
|
4072 |
if ( $taxIndex =~ /[0-9]+/ ){
|
|
4044 | 4073 |
if (hasContent(param($trn)) && hasContent(param($trv))) { |
4045 | 4074 |
debug("Registry processing taxon: $trn = ".param($trn)." $trv = ".param($trv)); |
4046 | 4075 |
$$templateVars{$trn} = param($trn); |
... | ... | |
4073 | 4102 |
if ($upload =~ /upload_/) { |
4074 | 4103 |
my $fileIndex = $upload; |
4075 | 4104 |
$fileIndex =~ s/upload_//; |
4076 |
if ( $fileIndex =~ /[0-9]/ ) { |
|
4105 |
if ( $fileIndex =~ /[0-9]+/ ) {
|
|
4077 | 4106 |
if (hasContent(param($upload))) { |
4078 | 4107 |
debug("Registry: returning filename: " . param($upload)); |
4079 | 4108 |
$$templateVars{"upload_$fileIndex"} = param($upload); |
Also available in: Unified diff
Cleaned up regexes used in register-dataset.cgi to support arbitrary numbers of elements for keywords. Cleaned up regexes for state selection, to omit default values. Added debug as a GET parameter, so a page can be debugged by appending `&debug=1'. Committed latest changes to file processing, to allow files to be deleted after returning to the entry page from confirmation or processing errors. Seperated out entryForm.js from entryForm.tmpl to simplify debugging.