Project

General

Profile

« Previous | Next » 

Revision 9063

Added by Jing Tao almost 10 years ago

Add the code to handle SID in the getLogRecords method.

View differences:

src/edu/ucsb/nceas/metacat/dataone/v1/MNodeService.java
441 441
			String pidFilter, Integer start, Integer count) throws InvalidRequest, InvalidToken,
442 442
			NotAuthorized, NotImplemented, ServiceFailure {
443 443
	    Log retLog = new Log();
444
	    if(pidFilter != null && !pidFilter.equals("")) {
444
	    if(pidFilter != null && !pidFilter.trim().equals("")) {
445 445
	        String serviceFailure = "1490";
446 446
	        String notFound = "1020";
447 447
	        Identifier pid = new Identifier();
src/edu/ucsb/nceas/metacat/dataone/v1/CNodeService.java
447 447
			InvalidRequest, ServiceFailure, NotAuthorized, NotImplemented,
448 448
			InsufficientResources {
449 449
	    Log retLog = new Log();
450
        if(pidFilter != null && !pidFilter.equals("")) {
450
        if(pidFilter != null && !pidFilter.trim().equals("")) {
451 451
            String serviceFailure = "1490";
452 452
            String notFound = "1020";
453 453
            Identifier pid = new Identifier();
src/edu/ucsb/nceas/metacat/dataone/D1NodeService.java
526 526
	  if (!isAdminAuthorized(session)) {
527 527
		  throw new NotAuthorized("1460", "Only the CN or admin is allowed to harvest logs from this node");
528 528
	  }
529
	  
529
    Log log = new Log();
530 530
    IdentifierManager im = IdentifierManager.getInstance();
531 531
    EventLog el = EventLog.getInstance();
532 532
    if ( fromDate == null ) {
......
552 552
    }
553 553

  
554 554
    String[] filterDocid = null;
555
    if (pidFilter != null) {
555
    if (pidFilter != null && !pidFilter.trim().equals("")) {
556
        //check if the given identifier is a sid. If it is sid, choose the current pid of the sid.
557
        Identifier pid = new Identifier();
558
        pid.setValue(pidFilter);
559
        String serviceFailureCode = "1490";
560
        Identifier sid = getPIDForSID(pid, serviceFailureCode);
561
        if(sid != null) {
562
            pid = sid;
563
        }
564
        pidFilter = pid.getValue();
556 565
		try {
557 566
	      String localId = im.getLocalId(pidFilter);
558 567
	      filterDocid = new String[] {localId};
......
560 569
	    	String msg = "Could not find localId for given pidFilter '" + pidFilter + "'";
561 570
	        logMetacat.warn(msg, ex);
562 571
	        //throw new InvalidRequest("1480", msg);
572
	        return log; //return 0 record
563 573
	    }
564 574
    }
565 575
    
566 576
    logMetacat.debug("fromDate: " + fromDate);
567 577
    logMetacat.debug("toDate: " + toDate);
568 578

  
569
    Log log = el.getD1Report(null, null, filterDocid, event,
579
    log = el.getD1Report(null, null, filterDocid, event,
570 580
        new java.sql.Timestamp(fromDate.getTime()),
571 581
        new java.sql.Timestamp(toDate.getTime()), false, start, count);
572 582
    

Also available in: Unified diff