Revision 2415
Added by sgarg over 19 years ago
src/perl/register-dataset.cgi | ||
---|---|---|
226 | 226 |
}elsif ($FORM::stage =~ "delete_confirm") { |
227 | 227 |
|
228 | 228 |
# Result from deleteData form. |
229 |
if($FORM::deleteData =~ "Delete data"){
|
|
229 |
if($FORM::deleteData =~ "Delete document"){
|
|
230 | 230 |
# delete Data |
231 | 231 |
deleteData(1); |
232 | 232 |
exit(0); |
... | ... | |
346 | 346 |
if (! $response) { |
347 | 347 |
push(@errorMessages, $metacat->getMessage()); |
348 | 348 |
push(@errorMessages, "Failed during login.\n"); |
349 |
} |
|
349 |
$$templateVars{'status'} = 'login_failure'; |
|
350 |
$$templateVars{'errorMessages'} = \@errorMessages; |
|
351 |
$$templateVars{'docid'} = $docid; |
|
352 |
$$templateVars{'cfg'} = $FORM::cfg; |
|
353 |
$$templateVars{'function'} = "submitted"; |
|
354 |
$$templateVars{'section'} = "Submission Status"; |
|
355 |
$template->process( $responseTemplate, $templateVars); |
|
356 |
exit(0); |
|
357 |
} else { |
|
350 | 358 |
|
351 |
debug( "Registry: A"); |
|
352 |
if ($FORM::docid eq "") { |
|
353 |
debug( "Registry: B1"); |
|
354 |
# document is being inserted |
|
355 |
my $notunique = "NOT_UNIQUE"; |
|
356 |
while ($notunique eq "NOT_UNIQUE") { |
|
357 |
$docid = newAccessionNumber($defaultScope); |
|
358 |
|
|
359 |
$xmldocWithDocID = $xmldoc; |
|
360 |
$xmldocWithDocID =~ s/docid/$docid/; |
|
361 |
|
|
362 |
# Code for testing the xml file being inserted#### |
|
363 |
#my $testFile = "/tmp/test.xml"; |
|
364 |
#open (TFILE,">$testFile") || die ("Cant open xml file...\n"); |
|
365 |
#print TFILE $xmldoc; |
|
366 |
#close(TFILE); |
|
367 |
#### |
|
359 |
debug( "Registry: A"); |
|
360 |
if ($FORM::docid eq "") { |
|
361 |
debug( "Registry: B1"); |
|
362 |
# document is being inserted |
|
363 |
my $notunique = "NOT_UNIQUE"; |
|
364 |
while ($notunique eq "NOT_UNIQUE") { |
|
365 |
$docid = newAccessionNumber($defaultScope); |
|
366 |
|
|
367 |
$xmldocWithDocID = $xmldoc; |
|
368 |
$xmldocWithDocID =~ s/docid/$docid/; |
|
368 | 369 |
|
369 |
$notunique = insertMetadata($xmldocWithDocID, $docid); |
|
370 |
# if (!$notunique) { |
|
371 |
# Write out the XML file for debugging purposes |
|
372 |
#my $testFile = $tmpdir . "/test-new.xml"; |
|
373 |
#open (TFILE,">$testFile") || die ("Cant open xml file...\n"); |
|
374 |
#print TFILE $newdoc; |
|
375 |
#close(TFILE); |
|
376 |
# } |
|
377 |
|
|
378 |
# The id wasn't unique, so update our lastid file |
|
379 |
if ($notunique eq "NOT_UNIQUE") { |
|
380 |
debug( "Registry: Updating lastid (B1.1)"); |
|
381 |
updateLastId($defaultScope); |
|
370 |
# Code for testing the xml file being inserted#### |
|
371 |
#my $testFile = "/tmp/test.xml"; |
|
372 |
#open (TFILE,">$testFile") || die ("Cant open xml file...\n"); |
|
373 |
#print TFILE $xmldoc; |
|
374 |
#close(TFILE); |
|
375 |
#### |
|
376 |
|
|
377 |
$notunique = insertMetadata($xmldocWithDocID, $docid); |
|
378 |
# if (!$notunique) { |
|
379 |
# Write out the XML file for debugging purposes |
|
380 |
#my $testFile = $tmpdir . "/test-new.xml"; |
|
381 |
#open (TFILE,">$testFile") || die ("Cant open xml file...\n"); |
|
382 |
#print TFILE $newdoc; |
|
383 |
#close(TFILE); |
|
384 |
# } |
|
385 |
|
|
386 |
# The id wasn't unique, so update our lastid file |
|
387 |
if ($notunique eq "NOT_UNIQUE") { |
|
388 |
debug( "Registry: Updating lastid (B1.1)"); |
|
389 |
updateLastId($defaultScope); |
|
390 |
} |
|
382 | 391 |
} |
383 |
} |
|
384 |
debug("Registry: B2"); |
|
385 |
if ($notunique ne "SUCCESS") { |
|
386 |
debug("Registry: NO SUCCESS"); |
|
387 |
debug("Message is: $notunique"); |
|
388 |
push(@errorMessages, $notunique); |
|
389 |
} |
|
392 |
debug("Registry: B2"); |
|
393 |
if ($notunique ne "SUCCESS") { |
|
394 |
debug("Registry: NO SUCCESS"); |
|
395 |
debug("Message is: $notunique"); |
|
396 |
push(@errorMessages, $notunique); |
|
397 |
} |
|
390 | 398 |
|
391 |
debug("Registry: B3"); |
|
392 |
} else { |
|
393 |
# document is being modified |
|
394 |
$docid = $FORM::docid; |
|
399 |
debug("Registry: B3");
|
|
400 |
} else {
|
|
401 |
# document is being modified
|
|
402 |
$docid = $FORM::docid;
|
|
395 | 403 |
|
396 |
my $x; |
|
397 |
my $y; |
|
398 |
my $z; |
|
399 |
|
|
400 |
($x, $y, $z) = split(/\./, $docid); |
|
401 |
$z++; |
|
402 |
$docid = "$x.$y.$z"; |
|
404 |
my $x;
|
|
405 |
my $y;
|
|
406 |
my $z;
|
|
407 |
|
|
408 |
($x, $y, $z) = split(/\./, $docid);
|
|
409 |
$z++;
|
|
410 |
$docid = "$x.$y.$z";
|
|
403 | 411 |
|
404 |
$xmldoc =~ s/docid/$docid/; |
|
412 |
$xmldoc =~ s/docid/$docid/;
|
|
405 | 413 |
|
406 |
my $response = $metacat->update($docid, $xmldoc); |
|
414 |
my $response = $metacat->update($docid, $xmldoc);
|
|
407 | 415 |
|
408 |
if (! $response) { |
|
409 |
push(@errorMessages, $metacat->getMessage()); |
|
410 |
push(@errorMessages, "Failed while updating.\n"); |
|
411 |
} |
|
416 |
if (! $response) {
|
|
417 |
push(@errorMessages, $metacat->getMessage());
|
|
418 |
push(@errorMessages, "Failed while updating.\n");
|
|
419 |
}
|
|
412 | 420 |
|
413 |
if (scalar(@errorMessages)) { |
|
414 |
debug("Registry: ErrorMessages defined in modify."); |
|
421 |
if (scalar(@errorMessages)) { |
|
422 |
debug("Registry: ErrorMessages defined in modify."); |
|
423 |
|
|
424 |
$$templateVars{'docid'} = $FORM::docid; |
|
425 |
copyFormToTemplateVars(); |
|
426 |
$$templateVars{'status'} = 'failure'; |
|
427 |
$$templateVars{'errorMessages'} = \@errorMessages; |
|
428 |
$error = 1; |
|
429 |
} else { |
|
430 |
$$templateVars{'docid'} = $docid; |
|
431 |
$$templateVars{'cfg'} = $FORM::cfg; |
|
432 |
} |
|
415 | 433 |
|
416 |
$$templateVars{'docid'} = $FORM::docid; |
|
417 |
copyFormToTemplateVars(); |
|
418 |
$$templateVars{'status'} = 'failure'; |
|
419 |
$$templateVars{'errorMessages'} = \@errorMessages; |
|
420 |
$error = 1; |
|
421 |
} else { |
|
422 |
$$templateVars{'docid'} = $docid; |
|
423 |
$$templateVars{'cfg'} = $FORM::cfg; |
|
424 |
} |
|
425 |
|
|
426 |
#if (! $error) { |
|
427 |
#sendNotification($docid, $mailhost, $sender, $recipient); |
|
428 |
#} |
|
434 |
#if (! $error) { |
|
435 |
#sendNotification($docid, $mailhost, $sender, $recipient); |
|
436 |
#} |
|
429 | 437 |
|
430 |
# Create our HTML response and send it back |
|
431 |
$$templateVars{'function'} = "modified"; |
|
432 |
$$templateVars{'section'} = "Modification Status"; |
|
433 |
$template->process( $responseTemplate, $templateVars); |
|
434 |
|
|
435 |
exit(0); |
|
438 |
# Create our HTML response and send it back |
|
439 |
$$templateVars{'function'} = "modified"; |
|
440 |
$$templateVars{'section'} = "Modification Status"; |
|
441 |
$template->process( $responseTemplate, $templateVars); |
|
442 |
|
|
443 |
exit(0); |
|
444 |
} |
|
436 | 445 |
} |
437 | 446 |
} |
438 | 447 |
|
... | ... | |
564 | 573 |
my $chkUser = shift; |
565 | 574 |
my @invalidParams; |
566 | 575 |
|
567 |
push(@invalidParams, "Provider's first name is missing.")
|
|
576 |
push(@invalidParams, "First name of person entering the form is missing.")
|
|
568 | 577 |
unless hasContent($FORM::providerGivenName); |
569 |
push(@invalidParams, "Provider's last name is missing.")
|
|
578 |
push(@invalidParams, "Last name of person entering the form is missing.")
|
|
570 | 579 |
unless hasContent($FORM::providerSurName); |
571 |
push(@invalidParams, "Name of site is missing.") |
|
580 |
push(@invalidParams, "Data set title is missing.") |
|
581 |
unless hasContent($FORM::title); |
|
582 |
push(@invalidParams, "Organization name is missing.") |
|
572 | 583 |
unless (hasContent($FORM::site) || $FORM::site =~ /elect/ || |
573 | 584 |
$FORM::cfg eq "nceas"); |
574 |
push(@invalidParams, "Data set title is missing.") |
|
575 |
unless hasContent($FORM::title); |
|
576 |
push(@invalidParams, "Originator's first name is missing.") |
|
585 |
push(@invalidParams, "First name of principal data set owner is missing.") |
|
577 | 586 |
unless hasContent($FORM::origNamefirst0); |
578 |
push(@invalidParams, "Originator's last name is missing.")
|
|
587 |
push(@invalidParams, "Last name of principal data set owner is missing.")
|
|
579 | 588 |
unless hasContent($FORM::origNamelast0); |
580 |
push(@invalidParams, "Abstract is missing.")
|
|
589 |
push(@invalidParams, "Data set abstract is missing.")
|
|
581 | 590 |
unless hasContent($FORM::abstract); |
582 | 591 |
if($FORM::hasTemporal eq 'true'){ |
583 |
push(@invalidParams, "Beginning year of data set is missing.")
|
|
592 |
push(@invalidParams, "Year of start date is missing.")
|
|
584 | 593 |
unless (hasContent($FORM::beginningYear) || $FORM::temporalRequired ne 'true'); |
585 |
push(@invalidParams, "Ending year has been specified but beginning year of data set is missing.")
|
|
594 |
push(@invalidParams, "Year of stop date has been specified but year of start date is missing.")
|
|
586 | 595 |
if ((!hasContent($FORM::beginningYear)) && hasContent($FORM::endingYear)); |
587 | 596 |
} |
588 | 597 |
push(@invalidParams, "Geographic description is missing.") |
... | ... | |
618 | 627 |
} |
619 | 628 |
|
620 | 629 |
if (hasContent($FORM::beginningYear) && !($FORM::beginningYear =~ /[0-9][0-9][0-9][0-9]/)){ |
621 |
push(@invalidParams, "Invalid beginning year specified.")
|
|
630 |
push(@invalidParams, "Invalid year of start date specified.")
|
|
622 | 631 |
} |
623 | 632 |
|
624 | 633 |
if (hasContent($FORM::endingYear) && !($FORM::endingYear =~ /[0-9][0-9][0-9][0-9]/)){ |
625 |
push(@invalidParams, "Invalid ending year specified.")
|
|
634 |
push(@invalidParams, "Invalid year of stop date specified.")
|
|
626 | 635 |
} |
627 | 636 |
|
628 | 637 |
# If the "use site" coord. box is checked and if the site is in |
... | ... | |
717 | 726 |
if (hasContent($FORM::methodTitle) && ( !(scalar(@FORM::methodPara) > 0) |
718 | 727 |
|| (! hasContent($FORM::methodPara[0])))); |
719 | 728 |
push(@invalidParams, |
720 |
"You must provide a method description if you provide a study extent description.")
|
|
729 |
"You must provide a method description if you provide an extent of study description.")
|
|
721 | 730 |
if (hasContent($FORM::studyExtentDescription) && (!(scalar(@FORM::methodPara) > 0) |
722 | 731 |
|| (! hasContent($FORM::methodPara[0])))); |
723 | 732 |
push(@invalidParams, |
724 |
"You must provide both a study extent description and a sampling description, or neither.")
|
|
733 |
"You must provide both an extent of study description and a sampling description, or neither.")
|
|
725 | 734 |
if ( |
726 | 735 |
(hasContent($FORM::studyExtentDescription) && !hasContent($FORM::samplingDescription)) || |
727 | 736 |
(!hasContent($FORM::studyExtentDescription) && hasContent($FORM::samplingDescription)) |
728 | 737 |
); |
729 | 738 |
} |
730 | 739 |
|
731 |
push(@invalidParams, "Contact first name is missing.")
|
|
740 |
push(@invalidParams, "First name of data set contact is missing.")
|
|
732 | 741 |
unless (hasContent($FORM::origNamefirstContact) || |
733 | 742 |
$FORM::useOrigAddress); |
734 |
push(@invalidParams, "Contact last name is missing.")
|
|
743 |
push(@invalidParams, "Last name of data set contact is missing.")
|
|
735 | 744 |
unless (hasContent($FORM::origNamelastContact) || |
736 | 745 |
$FORM::useOrigAddress); |
737 | 746 |
push(@invalidParams, "Data medium is missing.") |
738 | 747 |
unless (hasContent($FORM::dataMedium) || $FORM::dataMedium =~ /elect/); |
748 |
push(@invalidParams, "Usage constraints is missing.") |
|
749 |
unless (hasContent($FORM::useConstraints)); |
|
739 | 750 |
|
740 | 751 |
return \@invalidParams; |
741 | 752 |
} |
... | ... | |
801 | 812 |
|
802 | 813 |
################################################################################ |
803 | 814 |
# |
815 |
# Subroutine for replacing characters not recognizable by XML and otherwise |
|
816 |
# except for ", > amd <. |
|
817 |
# |
|
818 |
################################################################################ |
|
819 |
sub delNormalize{ |
|
820 |
my $val = shift; |
|
821 |
|
|
822 |
$val =~ s/&/&/g; |
|
823 |
|
|
824 |
$val =~ s/%/%/g; |
|
825 |
|
|
826 |
my $returnVal = ""; |
|
827 |
|
|
828 |
foreach (split(//,$val)){ |
|
829 |
my $var = unpack "C*", $_; |
|
830 |
|
|
831 |
if($var<128 && $var>31){ |
|
832 |
$returnVal=$returnVal.$_; |
|
833 |
} elsif ($var<32){ |
|
834 |
if($var == 10){ |
|
835 |
$returnVal=$returnVal.$_; |
|
836 |
} |
|
837 |
if($var == 13){ |
|
838 |
$returnVal=$returnVal.$_; |
|
839 |
} |
|
840 |
if($var == 9){ |
|
841 |
$returnVal=$returnVal.$_; |
|
842 |
} |
|
843 |
} else { |
|
844 |
$returnVal=$returnVal."&#".$var.";"; |
|
845 |
} |
|
846 |
} |
|
847 |
|
|
848 |
$returnVal =~ s/&/%26/g; |
|
849 |
return $returnVal; |
|
850 |
} |
|
851 |
|
|
852 |
|
|
853 |
################################################################################ |
|
854 |
# |
|
804 | 855 |
# Subroutine for replacing characters that might create problem in HTML. |
805 |
# Specifically written for " being used in any text field. This create a |
|
856 |
# Specifically written for " being used in any text field. This creates a
|
|
806 | 857 |
# problem in confirmData template, when you specify input name value pair |
807 | 858 |
# with value having a " in it. |
808 | 859 |
# |
... | ... | |
1080 | 1131 |
$doc .= "<keywordSet>\n"; |
1081 | 1132 |
$doc .= "<keyword "; |
1082 | 1133 |
if (hasContent(param("kwType" . $tmp1)) && |
1083 |
(param("kwType" . $tmp1) !~ "none") ) {
|
|
1134 |
(param("kwType" . $tmp1) !~ "None") ) {
|
|
1084 | 1135 |
$doc .= "keywordType=\""; |
1085 | 1136 |
$doc .= lc(param("kwType" . $tmp1)); |
1086 | 1137 |
$doc .= "\""; |
... | ... | |
2209 | 2260 |
|
2210 | 2261 |
$httpMessage = $metacat->read($docid); |
2211 | 2262 |
$doc = $httpMessage->content(); |
2212 |
$doc = normalize($doc);
|
|
2263 |
$doc = delNormalize($doc);
|
|
2213 | 2264 |
$xmldoc = $parser->parse_string($doc); |
2214 | 2265 |
|
2215 | 2266 |
if ($xmldoc eq "") { |
Also available in: Unified diff
Fixed some bugs from previous commits. Veronique changes the text of error messages. Added a new stage to distinguish errors because of logins.