Revision 4010
Added by Jing Tao over 16 years ago
register-dataset.cgi | ||
---|---|---|
179 | 179 |
if ($FORM::debug) { |
180 | 180 |
$debug = $FORM::debug; |
181 | 181 |
} |
182 |
|
|
183 |
# 1.8.1 temporary baseUrl fix |
|
184 |
my $baseUrl = $metacatUrl; |
|
185 |
$baseUrl =~ s/metacat$//; |
|
186 |
|
|
182 | 187 |
my $lat = $config->get('lat'); |
183 | 188 |
my $lon = $config->get('lon'); |
184 | 189 |
|
... | ... | |
213 | 218 |
$$templateVars{'orgabbrev'} = $orgabbrev; |
214 | 219 |
$$templateVars{'orgurl'} = $orgurl; |
215 | 220 |
$$templateVars{'orgfilter'} = $orgfilter; |
221 |
$$templateVars{'baseUrl'} = $baseUrl; |
|
216 | 222 |
|
217 | 223 |
debug("Registry: Initialized -- stage set: $FORM::stage"); |
218 | 224 |
|
... | ... | |
234 | 240 |
exit(0); |
235 | 241 |
} |
236 | 242 |
|
243 |
# FIXME: temporary 1.8.1 fix to prevent missing upload directory from causing errors |
|
244 |
if (not -W $tmpdir) { |
|
245 |
debug("Registry Error: Can't write files to $tmpdir, disabling file uploads"); |
|
246 |
#push(@errorMessages, "Unable to write files to temporary folder. Email sysadmin."); |
|
247 |
$hasUpload = 'false'; |
|
248 |
} |
|
249 |
|
|
237 | 250 |
# Process the form based on stage parameter. |
238 | 251 |
if ($FORM::stage =~ "loginform") { |
239 | 252 |
print "Content-type: text/html\n\n"; |
... | ... | |
1038 | 1051 |
my $fileNum = shift; |
1039 | 1052 |
my $fileHash = param("upload_$fileNum"); |
1040 | 1053 |
my $fileName = param("uploadname_$fileNum"); |
1054 |
my $filePerm = param("uploadperm_$fileNum"); |
|
1041 | 1055 |
my $contentType = param("uploadtype_$fileNum"); |
1042 | 1056 |
my $cleanName = $fileName; |
1043 | 1057 |
|
... | ... | |
1086 | 1100 |
'fileName' => $cleanName, |
1087 | 1101 |
'fileSize' => $fileSize, |
1088 | 1102 |
'fileHash' => $fileHash, |
1103 |
'filePerm' => $filePerm, |
|
1089 | 1104 |
'contentType' => $contentType, |
1090 | 1105 |
'url' => $uploadUrl, |
1091 | 1106 |
'entityType' => $entityType, |
... | ... | |
1115 | 1130 |
# file is in Metacat, generate the pertinent EML elements |
1116 | 1131 |
my $contentType = uploadInfo($fileName)->{'Content-Type'}; |
1117 | 1132 |
|
1133 |
# occasionally CGI.pm doesn't get the file info. In this case, |
|
1134 |
# use a default MIME type of text/plain. Seems fixed in the newer CGI.pm: |
|
1135 |
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=313141 |
|
1136 |
if (!$contentType) { |
|
1137 |
$contentType = 'text/plain'; |
|
1138 |
} |
|
1139 |
|
|
1118 | 1140 |
my %dataInfo = ( 'fileName' => $fileName, |
1119 | 1141 |
'fileHash' => $fileHash, |
1120 | 1142 |
'contentType' => $contentType, |
... | ... | |
1175 | 1197 |
my $response = $metacat->upload($docid, $data); |
1176 | 1198 |
if (!$response) { |
1177 | 1199 |
my $uploadMsg = $metacat->getMessage(); |
1200 |
push(@errorMessages, "Failed to upload file. Error was: $uploadMsg\n"); |
|
1178 | 1201 |
debug("Registry: Upload -- Error is: $uploadMsg"); |
1179 | 1202 |
} else { |
1180 | 1203 |
debug("Registry: Upload -- Success! New docid $docid"); |
... | ... | |
1287 | 1310 |
$roleName = $defaultRole; |
1288 | 1311 |
} |
1289 | 1312 |
|
1290 |
#debug("XXXXX role name: " . $roleName); |
|
1291 | 1313 |
push (@{$orig{$roleName}}, [$first, $last, $origRole]); |
1292 | 1314 |
} |
1293 | 1315 |
} |
... | ... | |
1364 | 1386 |
my $skinAccess = allowElement($username, 'all'); |
1365 | 1387 |
|
1366 | 1388 |
my $accessList = ""; |
1389 |
# form name => EML permission; roles akin to Apache model |
|
1390 |
my %accessRoles = ( |
|
1391 |
'public' => 'allow', |
|
1392 |
'private' => 'deny', |
|
1393 |
); |
|
1367 | 1394 |
|
1368 | 1395 |
while ( my ($docid, $data) = each(%entityObjects) ) { |
1396 |
my $defaultAccess = $accessRoles{$data->{'filePerm'}}; |
|
1369 | 1397 |
my $accessStub = qq|<additionalMetadata> |
1370 | 1398 |
<describes>$data->{'distribid'}</describes> |
1371 | 1399 |
<access authSystem="knb" order="denyFirst"> |
1372 | 1400 |
$skinAccess |
1373 | 1401 |
$userAccess |
1374 |
<deny>
|
|
1402 |
<$defaultAccess>
|
|
1375 | 1403 |
<principal>public</principal> |
1376 | 1404 |
<permission>read</permission> |
1377 |
</deny>
|
|
1405 |
</$defaultAccess>
|
|
1378 | 1406 |
</access> |
1379 | 1407 |
</additionalMetadata> |
1380 | 1408 |
|; |
... | ... | |
1411 | 1439 |
foreach my $x (@$a_ref) { |
1412 | 1440 |
my ($kw, $kwType) = @$x; |
1413 | 1441 |
$kwElem .= "<keyword "; |
1414 |
if (hasContent($kwType) && $kwType != "None") {
|
|
1442 |
if (hasContent($kwType) && $kwType ne "None") {
|
|
1415 | 1443 |
$kwElem.= "keywordType=\"".lc($kwType)."\""; |
1416 | 1444 |
} |
1417 | 1445 |
$kwElem .= ">$kw</keyword>\n"; |
... | ... | |
2172 | 2200 |
$aoCount++; |
2173 | 2201 |
} |
2174 | 2202 |
} |
2203 |
$$templateVars{'origEmail'} = findValue($node, '../electronicMailAddress'); |
|
2204 |
$$templateVars{'origNameOrg'} = findValue($node, '../organizationName'); |
|
2175 | 2205 |
} |
2176 | 2206 |
|
2177 | 2207 |
$results = $doc->findnodes('//dataset/creator/organizationName'); |
... | ... | |
2236 | 2266 |
$$templateVars{"origNamefirst$aoCount"} = findValue($tempNode, './givenName'); |
2237 | 2267 |
$$templateVars{"origNamelast$aoCount"} = findValue($tempNode, './surName'); |
2238 | 2268 |
$$templateVars{"origRole$aoCount"} = findValue($tempNode, '../role'); |
2239 |
$aoCount++;
|
|
2269 |
$aoCount++; |
|
2240 | 2270 |
} |
2241 | 2271 |
} |
2242 | 2272 |
} |
... | ... | |
2287 | 2317 |
|
2288 | 2318 |
my $count = 1; |
2289 | 2319 |
foreach $node ($results->get_nodelist) { |
2290 |
$tempResult = $node->findnodes('./keyword'); |
|
2291 |
if ($tempResult->size() > 1) { |
|
2292 |
errMoreThanOne("keyword"); |
|
2293 |
} else { |
|
2294 |
foreach $tempNode ($tempResult->get_nodelist) { |
|
2295 |
$$templateVars{"keyword$count"} = $tempNode->textContent(); |
|
2296 |
if ($tempNode->hasAttributes()) { |
|
2297 |
my @attlist = $tempNode->attributes(); |
|
2298 |
my $tmp = $attlist[0]->value; #convert the first letter to upper case |
|
2299 |
$tmp =~ s/\b(\w)/\U$1/g; |
|
2300 |
$$templateVars{"kwType$count"} = $tmp; |
|
2301 |
} |
|
2302 |
} |
|
2303 |
} |
|
2304 |
$$templateVars{"kwTh$count"} = findValue($node, "keywordThesaurus"); |
|
2305 |
$count++; |
|
2320 |
$tempResult = $node->findnodes('./keyword'); |
|
2321 |
foreach $tempNode ($tempResult->get_nodelist) { |
|
2322 |
$$templateVars{"keyword$count"} = $tempNode->textContent(); |
|
2323 |
$$templateVars{"kwTh$count"} = findValue($node, "keywordThesaurus"); |
|
2324 |
|
|
2325 |
if ($tempNode->hasAttributes()) { |
|
2326 |
my @attlist = $tempNode->attributes(); |
|
2327 |
my $tmp = $attlist[0]->value; #convert the first letter to upper case |
|
2328 |
$tmp =~ s/\b(\w)/\U$1/g; |
|
2329 |
$$templateVars{"kwType$count"} = $tmp; |
|
2330 |
} |
|
2331 |
$count++; |
|
2332 |
} |
|
2306 | 2333 |
} |
2307 | 2334 |
$$templateVars{'keyCount'} = $count; |
2308 | 2335 |
if($count > 0 ){ |
... | ... | |
2523 | 2550 |
dontOccur($node, "../positionName|../onlineURL|../userId", |
2524 | 2551 |
"positionName, onlineURL, userId in contact tag"); |
2525 | 2552 |
dontOccur($node, "./saluation", "saluation in contact tag"); |
2526 |
|
|
2553 |
|
|
2527 | 2554 |
$tempResult = $node->findnodes('../address|../phone|../electronicmailAddress|../organizationName'); |
2528 | 2555 |
if ($tempResult->size > 0) { |
2529 | 2556 |
$$templateVars{'origNamefirstContact'} = findValue($node, 'givenName'); |
2530 | 2557 |
$$templateVars{'origNamelastContact'} = findValue($node, 'surName'); |
2531 |
|
|
2558 |
|
|
2532 | 2559 |
my $tempResult2 = $node->findnodes('../address'); |
2533 | 2560 |
if ($tempResult2->size > 1) { |
2534 | 2561 |
errMoreThanOne("address"); |
... | ... | |
2541 | 2568 |
$$templateVars{'origCountryContact'} = findValue($tempNode2, 'country'); |
2542 | 2569 |
} |
2543 | 2570 |
} |
2544 |
|
|
2571 |
|
|
2545 | 2572 |
my $tempResult3 = $node->findnodes('../phone'); |
2546 | 2573 |
if ($tempResult3->size > 2) { |
2547 | 2574 |
errMoreThanN("phone"); |
... | ... | |
2566 | 2593 |
$$templateVars{'origNamelastContact'} = findValue($node, 'surName'); |
2567 | 2594 |
$$templateVars{'origNameOrgContact'} = findValue($node, '../organizationName'); |
2568 | 2595 |
} |
2596 |
$$templateVars{'origEmail'} = findValue($node, '../electronicMailAddress'); |
|
2597 |
$$templateVars{'origNameOrg'} = findValue($node, '../organizationName'); |
|
2598 |
|
|
2569 | 2599 |
} |
2570 | 2600 |
} |
2571 | 2601 |
|
... | ... | |
2678 | 2708 |
|
2679 | 2709 |
######################################################## |
2680 | 2710 |
|
2681 |
|
|
2682 | 2711 |
dontOccur($doc, "./dataTable", "dataTable"); |
2683 | 2712 |
dontOccur($doc, "./spatialRaster", "spatialRaster"); |
2684 | 2713 |
dontOccur($doc, "./spatialVector", "spatialVector"); |
2685 | 2714 |
dontOccur($doc, "./storedProcedure", "storedProcedure"); |
2686 | 2715 |
dontOccur($doc, "./view", "view"); |
2716 |
|
|
2687 | 2717 |
dontOccur($doc, "./otherEntity", "otherEntity"); |
2688 | 2718 |
dontOccur($doc, "./references", "references"); |
2689 | 2719 |
|
... | ... | |
2984 | 3014 |
$htmldoc .= "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\" \"http://www.w3.org/TR/html4/frameset.dtd\">"; |
2985 | 3015 |
$htmldoc .= "<html><head><title>Dataset Description: ".$docid."</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"></head>"; |
2986 | 3016 |
$htmldoc .= "<frameset rows=\"150,*\" cols=\"*\" frameborder=\"NO\" border=\"0\" framespacing=\"0\">"; |
2987 |
$htmldoc .= "<frame src=\"@systemidserver@@style-skins-path@/".$FORM::cfg."/header.html\" marginwidth=\"40\" name=\"topFrame\" scrolling=\"NO\" noresize>";
|
|
3017 |
$htmldoc .= "<frame src=\"@systemidserver@@style-skins-path@/".$FORM::cfg."/header.jsp\" marginwidth=\"40\" name=\"topFrame\" scrolling=\"NO\" noresize>";
|
|
2988 | 3018 |
$htmldoc .= "<frameset cols=\"200,*\" frameborder=\"NO\" border=\"0\" framespacing=\"0\">"; |
2989 | 3019 |
$htmldoc .= "<body></body><frame src=\"@cgi-prefix@/register-dataset.cgi?cfg=".$FORM::cfg."&stage=review_frame&docid=".$docid."\" name=\"rightFrame\" scrolling=\"NO\" noresize></frame>"; |
2990 | 3020 |
$htmldoc .= "<frame src=\"@systemidserver@@servlet-path@?action=read&qformat=".$FORM::cfg."&docid=".$docid."&insertTemplate=0\" name=\"mainFrame\">"; |
... | ... | |
3566 | 3596 |
# |
3567 | 3597 |
################################################################################ |
3568 | 3598 |
sub mod_sendNotification { |
3569 |
my $title = shift;
|
|
3570 |
my $contactEmailAddress = shift;
|
|
3571 |
my $contactName = shift;
|
|
3572 |
my $subject = shift;
|
|
3599 |
my $title = shift;
|
|
3600 |
my $contactEmailAddress = shift;
|
|
3601 |
my $contactName = shift;
|
|
3602 |
my $subject = shift;
|
|
3573 | 3603 |
|
3574 |
debug($subject);
|
|
3604 |
debug($subject);
|
|
3575 | 3605 |
# send notification to the user and the moderator |
3576 |
my $templateVars = { 'stage' => $FORM::stage }; |
|
3577 |
$$templateVars{'recipient'} = $recipient; |
|
3578 |
$$templateVars{'sender'} = $sender; |
|
3579 |
my ($x, $y, $z) = split(/\./, $FORM::docid); |
|
3580 |
my $docidWithoutRev = $x.".".$y; |
|
3581 |
$$templateVars{'docid'} = $docidWithoutRev; |
|
3582 |
$$templateVars{'comment'} = $FORM::review; |
|
3583 |
$$templateVars{'contactName'} = $contactName; |
|
3584 |
$$templateVars{'dpTitle'} = $title; |
|
3606 |
my $templateVars = { 'stage' => $FORM::stage }; |
|
3607 |
$$templateVars{'recipient'} = $recipient; |
|
3608 |
$$templateVars{'sender'} = $sender; |
|
3609 |
# form doesn't handle edit without revision; append |
|
3610 |
#my ($x, $y, $z) = split(/\./, $FORM::docid); |
|
3611 |
#my $docidWithoutRev = $x.".".$y; |
|
3612 |
#$$templateVars{'docid'} = $docidWithoutRev; |
|
3613 |
$$templateVars{'docid'} = $FORM::docid; |
|
3614 |
$$templateVars{'comment'} = $FORM::review; |
|
3615 |
$$templateVars{'contactName'} = $contactName; |
|
3616 |
$$templateVars{'dpTitle'} = $title; |
|
3585 | 3617 |
|
3586 |
$$templateVars{'recipient_status'} = 'moderator';
|
|
3587 |
sendNotification($mailhost, $sender, $recipient, $subject,
|
|
3588 |
$modEmailNotificationTemplate, $templateVars);
|
|
3589 |
if($contactEmailAddress ne ''){
|
|
3590 |
# send notification to contact email address specified in cfg
|
|
3591 |
$$templateVars{'recipient'} = $contactEmailAddress;
|
|
3592 |
$$templateVars{'recipient_status'} = 'user';
|
|
3593 |
sendNotification($mailhost, $sender, $contactEmailAddress,
|
|
3594 |
$subject, $modEmailNotificationTemplate, $templateVars);
|
|
3595 |
}
|
|
3618 |
$$templateVars{'recipient_status'} = 'moderator';
|
|
3619 |
sendNotification($mailhost, $sender, $recipient, $subject,
|
|
3620 |
$modEmailNotificationTemplate, $templateVars);
|
|
3621 |
if($contactEmailAddress ne ''){
|
|
3622 |
# send notification to contact email address specified in cfg
|
|
3623 |
$$templateVars{'recipient'} = $contactEmailAddress;
|
|
3624 |
$$templateVars{'recipient_status'} = 'user';
|
|
3625 |
sendNotification($mailhost, $sender, $contactEmailAddress,
|
|
3626 |
$subject, $modEmailNotificationTemplate, $templateVars);
|
|
3627 |
}
|
|
3596 | 3628 |
} |
3597 | 3629 |
|
3598 | 3630 |
################################################################################ |
... | ... | |
3665 | 3697 |
################################################################################ |
3666 | 3698 |
sub toConfirmData{ |
3667 | 3699 |
# Check if any invalid parameters |
3668 |
|
|
3700 |
|
|
3669 | 3701 |
my $invalidParams; |
3670 | 3702 |
if (! $error) { |
3671 |
$invalidParams = validateParameters(0);
|
|
3672 |
if (scalar(@$invalidParams)) {
|
|
3673 |
$$templateVars{'status'} = 'failure';
|
|
3674 |
$$templateVars{'invalidParams'} = $invalidParams;
|
|
3675 |
$error = 1;
|
|
3676 |
}
|
|
3703 |
$invalidParams = validateParameters(0);
|
|
3704 |
if (scalar(@$invalidParams)) {
|
|
3705 |
$$templateVars{'status'} = 'failure';
|
|
3706 |
$$templateVars{'invalidParams'} = $invalidParams;
|
|
3707 |
$error = 1;
|
|
3708 |
}
|
|
3677 | 3709 |
} |
3678 | 3710 |
|
3679 | 3711 |
$$templateVars{'providerGivenName'} = normalizeCD($FORM::providerGivenName); |
... | ... | |
3777 | 3809 |
$$templateVars{"kwType".$keyCount} = normalizeCD($keywordTypeArray->[$i]); |
3778 | 3810 |
$$templateVars{"kwTh".$keyCount} = normalizeCD($keywordThArray->[$i]); |
3779 | 3811 |
$keyCount++; |
3780 |
}
|
|
3781 |
}
|
|
3812 |
}
|
|
3813 |
} |
|
3782 | 3814 |
$$templateVars{'keyCount'} = $keyCount; |
3783 |
|
|
3815 |
|
|
3784 | 3816 |
$$templateVars{'addComments'} = normalizeCD($FORM::addComments); |
3785 | 3817 |
$$templateVars{'useConstraints'} = $FORM::useConstraints; |
3786 | 3818 |
if($FORM::useConstraints eq "other"){ |
... | ... | |
3820 | 3852 |
my $taxonNameArray = \@FORM::taxonName; |
3821 | 3853 |
my $taxonCount = 1; |
3822 | 3854 |
|
3823 |
for(my $i = 0; $i <= $#$taxonNameArray; $i++){
|
|
3855 |
for (my $i = 0; $i <= $#$taxonNameArray; $i++) {
|
|
3824 | 3856 |
if (hasContent($taxonRankArray->[$i]) && hasContent($taxonNameArray->[$i])) { |
3825 | 3857 |
debug("Registry processing keyword: trv = ".$taxonRankArray->[$i] |
3826 | 3858 |
." trn = ".$taxonNameArray->[$i]); |
3827 | 3859 |
$$templateVars{"taxonRankName".$taxonCount} = normalizeCD($taxonRankArray->[$i]); |
3828 | 3860 |
$$templateVars{"taxonRankValue".$taxonCount} = normalizeCD($taxonNameArray->[$i]); |
3829 | 3861 |
$taxonCount++; |
3830 |
}
|
|
3862 |
}
|
|
3831 | 3863 |
} |
3832 | 3864 |
|
3833 | 3865 |
$$templateVars{'taxaCount'} = $taxonCount-1; |
... | ... | |
3844 | 3876 |
$$templateVars{"upload_$upNum"} = param("upload_$upNum"); |
3845 | 3877 |
$$templateVars{"uploadname_$upNum"} = param("uploadname_$upNum"); |
3846 | 3878 |
$$templateVars{"uploadtype_$upNum"} = param("uploadtype_$upNum"); |
3879 |
$$templateVars{"uploadperm_$upNum"} = param("uploadperm_$upNum"); |
|
3847 | 3880 |
} |
3848 | 3881 |
} |
3849 | 3882 |
} |
... | ... | |
3862 | 3895 |
$$templateVars{"upload_$totalFileNum"} = $fileInfo->{'fileHash'}; |
3863 | 3896 |
$$templateVars{"uploadname_$totalFileNum"} = $fileInfo->{'fileName'}; |
3864 | 3897 |
$$templateVars{"uploadtype_$totalFileNum"} = $fileInfo->{'contentType'}; |
3898 |
$$templateVars{"uploadperm_$totalFileNum"} = param("uploadperm_$totalFileNum"); |
|
3865 | 3899 |
$uploadCount++; |
3866 | 3900 |
} |
3867 | 3901 |
} |
... | ... | |
4105 | 4139 |
$$templateVars{"upload_$fileIndex"} = param($upload); |
4106 | 4140 |
$$templateVars{"uploadname_$fileIndex"} = param("uploadname_$fileIndex"); |
4107 | 4141 |
$$templateVars{"uploadtype_$fileIndex"} = param("uploadtype_$fileIndex"); |
4142 |
$$templateVars{"uploadperm_$fileIndex"} = param("uploadperm_$fileIndex"); |
|
4108 | 4143 |
$uploadCount++; |
4109 | 4144 |
} |
4110 | 4145 |
} |
Also available in: Unified diff
Merge METACAT_1_8_1 to cvs head.