Project

General

Profile

« Previous | Next » 

Revision 9287

Added by Jing Tao over 9 years ago

In the replicate method, it will use the v1.getReplica method if the source node only supports v1 replication service.

View differences:

src/edu/ucsb/nceas/metacat/dataone/MNodeService.java
712 712
            
713 713
            // no local replica, get a replica
714 714
            if ( object == null ) {
715
                // session should be null to use the default certificate
716
                // location set in the Certificate manager
717
                object = mn.getReplica(thisNodeSession, pid);
715
                if(!supportV2Replication(mn.getCapabilities())) {
716
                    //the source node is not a v2 node, we should use the v1 replication
717
                    //this should be change when v3, v4 and et al comes out
718
                    org.dataone.client.v1.MNode mNodeV1 =  org.dataone.client.v1.itk.D1Client.getMN(sourceNode);
719
                    object = mNodeV1.get(thisNodeSession, pid);
720
                } else {
721
                 // session should be null to use the default certificate
722
                    // location set in the Certificate manager
723
                    object = mn.getReplica(thisNodeSession, pid);
724
                }
725
                
718 726
                logMetacat.info("MNodeService.getReplica() called for identifier "
719 727
                                + pid.getValue());
720 728

  
......
813 821
        return result;
814 822

  
815 823
    }
824
    
825
    /*
826
     * If the given node supports v2 replication.
827
     */
828
    private boolean supportV2Replication(Node node) throws InvalidRequest {
829
        return supportVersionReplication(node, "v2");
830
    }
831
    
832
    /*
833
     * If the given node support the the given version replication. Return true if it does.
834
     */
835
    private boolean supportVersionReplication(Node node, String version) throws InvalidRequest{
836
        boolean support = false;
837
        if(node == null) {
838
            throw new InvalidRequest("2153", "There is no capacity information about the node in the replicate.");
839
        } else {
840
            Services services = node.getServices();
841
            if(services == null) {
842
                throw new InvalidRequest("2153", "Can't get replica from a node which doesn't have the replicate service.");
843
            } else {
844
               List<Service> list = services.getServiceList();
845
               if(list == null) {
846
                   throw new InvalidRequest("2153", "Can't get replica from a node which doesn't have the replicate service.");
847
               } else {
848
                   for(Service service : list) {
849
                       if(service != null && service.getName() != null && service.getName().equals("MNReplication") && 
850
                               service.getVersion() != null && service.getVersion().equalsIgnoreCase(version) && service.getAvailable() == true ) {
851
                           support = true;
852
                           
853
                       }
854
                   }
855
               }
856
            }
857
        }
858
        return support;
859
    }
816 860

  
817 861
    /**
818 862
     * Return the object identified by the given object identifier

Also available in: Unified diff