Project

General

Profile

« Previous | Next » 

Revision 5201

Added by daigle almost 15 years ago

Get the latest revision from metacat when a modify call docid does not have a revision number.

View differences:

src/perl/register-dataset.cgi
275 275
        }
276 276
        $$templateVars{'siteList'} = \@sortedSites;
277 277
        $$templateVars{'section'} = "Modification Form";
278
        $$templateVars{'docid'} = $FORM::docid;
278
        my ($foundScope, $id, $rev) = split(/\./, $FORM::docid);
279
        if (! $rev) {
280
        	my $metacat = Metacat->new($metacatUrl);
281
        	my $lastRev = $metacat->getLastRevision($FORM::docid);
282
        	$$templateVars{'docid'} = $FORM::docid . "." . $lastRev
283
        } else {
284
        	$$templateVars{'docid'} = $FORM::docid;
285
        }
279 286
        modifyData();
280 287
    }
281 288
    exit();
src/perl/Metacat/Metacat.pm
379 379
                 );
380 380

  
381 381
  my $response = $self->sendData(%postData);
382
  if (($response) && $response->content =~ /<docid>(.*)<\/docid>/s) {
382
  if (($response) && $response->content =~  /<docid>(.*)<\/docid>/s) {
383 383
      $returnval = "$1";
384 384
  } elsif (($response)) {
385 385
    $returnval = 0;
......
392 392

  
393 393
  return $returnval;
394 394
}
395

  
395 396
#############################################################
397
# subroutine to get the maximimum id in a series
398
# If success, return max id, else return 0
399
#############################################################
400
sub getLastRevision {
401
  my $self = shift;
402
  my $docid = shift;
403

  
404
  my $returnval = 0;
405

  
406
  my %postData = ( action => 'getrevisionanddoctype',
407
                   docid => $docid
408
                 );
409

  
410
  my $response = $self->sendData(%postData);
411
  if (($response) && $response->content =~ /(.*);(.*)/s)  {
412
      $returnval = "$1";
413
  } elsif (($response)) {
414
    $returnval = 0;
415
    #print "Error response from sendData!\n";
416
    #print $response->content, "\n";
417
  } else {
418
    $returnval = 0;
419
    #print "Invalid response from sendData!\n";
420
  }
421

  
422
  return $returnval;
423
}
424

  
425
#############################################################
396 426
# subroutine to get the message returned from the last executed
397 427
# metacat action.  These are generally XML formatted messages.
398 428
#############################################################
src/edu/ucsb/nceas/metacat/DBUtil.java
823 823
      return MAXMUM;
824 824
    }
825 825
  }
826
 
827
  /**
828
   * Method to return max rev number in xml_revision for given docid.
829
   * @param docId
830
   * @return integer that holds max revision number
831
   * @throws SQLException
832
   */
833
  public static int getMaxRevFromRevisionTable(String docIdWithoutRev) throws SQLException
834
  {
835
	  int rev = NONEEXIST;
836
	  
837
	  Vector<Integer> revList = getRevListFromRevisionTable(docIdWithoutRev);
838
	  
839
	  for (Integer currentRev : revList) {
840
		  if (currentRev > rev) {
841
			  rev = currentRev;
842
		  }
843
	  }
844
	  
845
	  return rev;
846
  }
826 847
  
827 848
  /**
828 849
   * Method to return a rev list in xml_revision for given docid.

Also available in: Unified diff