82 |
82 |
$config->define("guideTemplate", { DEFAULT => 'crap.tmpl'} );
|
83 |
83 |
$config->define("confirmDataTemplate", { DEFAULT => 'crap.tmpl'} );
|
84 |
84 |
$config->define("deleteDataTemplate", { DEFAULT => 'crap.tmpl'} );
|
|
85 |
$config->define("debug", { DEFAULT => '0'} );
|
85 |
86 |
$config->define("lat", { ARGCOUNT => ARGCOUNT_HASH} );
|
86 |
87 |
$config->define("lon", { ARGCOUNT => ARGCOUNT_HASH} );
|
87 |
88 |
|
... | ... | |
116 |
117 |
my $sender = $config->sender();
|
117 |
118 |
my $recipient = $config->recipient();
|
118 |
119 |
my $adminname = $config->adminname();
|
|
120 |
my $debug = $config->debug();
|
119 |
121 |
my $lat = $config->get('lat');
|
120 |
122 |
my $lon = $config->get('lon');
|
121 |
123 |
|
... | ... | |
286 |
288 |
push(@errorMessages, "Failed during login.\n");
|
287 |
289 |
}
|
288 |
290 |
|
289 |
|
if($FORM::docid eq ""){
|
|
291 |
debug( "Registry: A");
|
|
292 |
if ($FORM::docid eq "") {
|
|
293 |
debug( "Registry: B1");
|
290 |
294 |
# document is being inserted
|
291 |
295 |
my $notunique = "NOT_UNIQUE";
|
292 |
296 |
while ($notunique eq "NOT_UNIQUE") {
|
... | ... | |
307 |
311 |
#print TFILE $newdoc;
|
308 |
312 |
#close(TFILE);
|
309 |
313 |
# }
|
|
314 |
|
|
315 |
# The id wasn't unique, so update our lastid file
|
|
316 |
if ($notunique eq "NOT_UNIQUE") {
|
|
317 |
updateLastId($defaultScope);
|
|
318 |
}
|
310 |
319 |
}
|
311 |
|
if (! ($notunique eq "SUCCESS")) {
|
|
320 |
debug("Registry: B2");
|
|
321 |
if ($notunique ne "SUCCESS") {
|
|
322 |
debug("Registry: NO SUCCESS");
|
|
323 |
debug("Message is: $notunique");
|
312 |
324 |
push(@errorMessages, $notunique);
|
313 |
325 |
}
|
|
326 |
debug("Registry: B3");
|
314 |
327 |
} else {
|
315 |
328 |
# document is being modified
|
316 |
329 |
$docid = $FORM::docid;
|
... | ... | |
330 |
343 |
if (! $response) {
|
331 |
344 |
push(@errorMessages, $metacat->getMessage());
|
332 |
345 |
push(@errorMessages, "Failed while updating.\n");
|
333 |
|
} else {
|
334 |
|
#deleteData(0);
|
335 |
346 |
}
|
336 |
347 |
|
337 |
348 |
if (scalar(@errorMessages)) {
|
|
349 |
debug("Registry: ErrorMessages defined in modify.");
|
338 |
350 |
$$templateVars{'status'} = 'failure';
|
339 |
351 |
$$templateVars{'errorMessages'} = \@errorMessages;
|
340 |
352 |
$error = 1;
|
341 |
353 |
}
|
342 |
354 |
|
343 |
|
#if (! $error) {
|
344 |
|
#sendNotification($docid, $mailhost, $sender, $recipient);
|
345 |
|
#}
|
|
355 |
#if (! $error) {
|
|
356 |
#sendNotification($docid, $mailhost, $sender, $recipient);
|
|
357 |
#}
|
346 |
358 |
|
347 |
359 |
# Create our HTML response and send it back
|
348 |
360 |
$$templateVars{'function'} = "modified";
|
... | ... | |
353 |
365 |
}
|
354 |
366 |
}
|
355 |
367 |
|
|
368 |
debug("Registry: C");
|
356 |
369 |
|
357 |
370 |
if (scalar(@errorMessages)) {
|
|
371 |
debug("Registry: ErrorMessages defined.");
|
358 |
372 |
$$templateVars{'status'} = 'failure';
|
359 |
373 |
$$templateVars{'errorMessages'} = \@errorMessages;
|
360 |
374 |
$error = 1;
|
... | ... | |
374 |
388 |
|
375 |
389 |
################################################################################
|
376 |
390 |
#
|
|
391 |
# Subroutine for updating a metacat id for a given scope to the highest value
|
|
392 |
#
|
|
393 |
################################################################################
|
|
394 |
sub updateLastId {
|
|
395 |
my $scope = shift;
|
|
396 |
|
|
397 |
my $errormsg = 0;
|
|
398 |
my $docid = $metacat->getLastId($scope);
|
|
399 |
|
|
400 |
if ($docid =~ /null/) {
|
|
401 |
# No docids with this scope present, so do nothing
|
|
402 |
} elsif ($docid) {
|
|
403 |
# Update the lastid file for this scope
|
|
404 |
(my $foundScope, my $id, my $rev) = split(/\./, $docid);
|
|
405 |
debug("Docid is: $docid\n");
|
|
406 |
debug("Lastid is: $id");
|
|
407 |
my $scopeFile = $cfgdir . "/" . $FORM::cfg . "/" . $scope . ".lastid";
|
|
408 |
open(LASTID, ">$scopeFile") or
|
|
409 |
die "Failed to open lastid file for writing!";
|
|
410 |
print LASTID $id, "\n";
|
|
411 |
close(LASTID);
|
|
412 |
} else {
|
|
413 |
$errormsg = $metacat->getMessage();
|
|
414 |
debug("Error in getLastId: $errormsg");
|
|
415 |
}
|
|
416 |
}
|
|
417 |
|
|
418 |
################################################################################
|
|
419 |
#
|
377 |
420 |
# Subroutine for inserting a document to metacat
|
378 |
421 |
#
|
379 |
422 |
################################################################################
|
... | ... | |
2426 |
2469 |
#}
|
2427 |
2470 |
|
2428 |
2471 |
|
|
2472 |
################################################################################
|
|
2473 |
#
|
|
2474 |
# print debugging messages to stderr
|
|
2475 |
#
|
|
2476 |
################################################################################
|
|
2477 |
sub debug {
|
|
2478 |
my $msg = shift;
|
|
2479 |
|
|
2480 |
if ($debug) {
|
|
2481 |
print STDERR "$msg\n";
|
|
2482 |
}
|
|
2483 |
}
|
Updates that allow registry script to update the lastid field more efficiently
by calling the metacat 'getlastdocid' function for a given scope. Also some
debugging support added, and a bug where the error message was inproperly
saved across calls to metacat, resulting in spurious error messages.