Project

General

Profile

« Previous | Next » 

Revision 9327

Added by Jing Tao over 9 years ago

Put a the systemMetadataChanged method into a queue, so it will not hold the block.

View differences:

src/edu/ucsb/nceas/metacat/restservice/v2/MNResourceHandler.java
667 667
        throws NotImplemented, ServiceFailure, NotAuthorized, InvalidRequest, 
668 668
        InvalidToken {
669 669

  
670
        long serialVersion = 0L;
670
        //final long serialVersion = 0L;
671 671
        String serialVersionStr = null;
672
        Date dateSysMetaLastModified = null;
673 672
        String dateSysMetaLastModifiedStr = null;
674
        Identifier pid = null;
675 673
        
676 674
        // mkae sure we have the multipart params
677 675
        try {
......
681 679
		}
682 680
        
683 681
        // get the pid
682
        String id = null;
684 683
        try {
685
        	String id = multipartparams.get("pid").get(0);
686
        	pid = new Identifier();
687
            pid.setValue(id);            
684
        	id = multipartparams.get("pid").get(0);
688 685
        } catch (NullPointerException e) {
689 686
            String msg = "The 'pid' must be provided as a parameter and was not.";
690 687
            logMetacat.error(msg);
691 688
            throw new InvalidRequest("1334", msg);
692
        }      
689
        }  
690
        final Identifier pid = new Identifier();
691
        pid.setValue(id);
693 692
        
694 693
        // get the serialVersion
695 694
        try {
696 695
            serialVersionStr = multipartparams.get("serialVersion").get(0);
697
            serialVersion = new Long(serialVersionStr).longValue();
698
            
699 696
        } catch (NullPointerException e) {
700 697
            String msg = "The 'serialVersion' must be provided as a parameter and was not.";
701 698
            logMetacat.error(msg);
702 699
            throw new InvalidRequest("1334", msg);
703 700
            
704
        }       
701
        }  
705 702
        
703
        final long serialVersion = (new Long(serialVersionStr)).longValue();
704
        
706 705
        // get the dateSysMetaLastModified
707 706
        try {
708 707
            dateSysMetaLastModifiedStr = multipartparams.get("dateSysMetaLastModified").get(0);
709
            dateSysMetaLastModified = DateTimeMarshaller.deserializeDateToUTC(dateSysMetaLastModifiedStr);
710 708
            
709
            
711 710
        } catch (NullPointerException e) {
712 711
            String msg = 
713 712
                "The 'dateSysMetaLastModified' must be provided as a " + 
......
715 714
            logMetacat.error(msg);
716 715
            throw new InvalidRequest("1334", msg);
717 716
            
718
        }       
717
        }      
718
        final Date dateSysMetaLastModified = DateTimeMarshaller.deserializeDateToUTC(dateSysMetaLastModifiedStr);
719 719
        
720
        // call the service
721
        MNodeService.getInstance(request).systemMetadataChanged(session, pid, serialVersion, dateSysMetaLastModified);
720
        // run it in a thread to avoid connection timeout
721
        Runnable runner = new Runnable() {
722
            @Override
723
            public void run() {
724
                try {
725
                   // call the service
726
                    MNodeService.getInstance(request).systemMetadataChanged(session, pid, serialVersion, dateSysMetaLastModified);
727
                } catch (Exception e) {
728
                    logMetacat.error("Error running replication: " + e.getMessage(), e);
729
                    throw new RuntimeException(e.getMessage(), e);
730
                }
731
            }
732
        };
733
        // submit the task, and that's it
734
        executor.submit(runner);
735
        
736
        // thread was started, so we return success
722 737
        response.setStatus(200);
723 738
    }
724 739
    

Also available in: Unified diff