Project

General

Profile

« Previous | Next » 

Revision 10270

Added by Jing Tao over 7 years ago

Removed the duplicated code to check the checksum in the replicate method since the method D1Node.create, which is called by the replicate method, has the mechanism.

View differences:

src/edu/ucsb/nceas/metacat/dataone/MNodeService.java
882 882

  
883 883
            // verify checksum on the object, if supported
884 884
            logMetacat.info("MNodeService.replicate - the class of object inputstream is "+object.getClass().getCanonicalName()+". Does it support the reset method? The answer is "+object.markSupported());
885
            if (object.markSupported()) {
886
                Checksum givenChecksum = sysmeta.getChecksum();
887
                Checksum computedChecksum = null;
888
                try {
889
                    computedChecksum = ChecksumUtil.checksum(object, givenChecksum.getAlgorithm());
890
                    object.reset();
891 885

  
892
                } catch (Exception e) {
893
                    String msg = "Error computing checksum on replica: " + e.getMessage();
894
                    logMetacat.error(msg);
895
                    ServiceFailure sf = new ServiceFailure("2151", msg);
896
                    sf.initCause(e);
897
                    setReplicationStatus(thisNodeSession, pid, nodeId, ReplicationStatus.FAILED, sf);
898
                    throw sf;
899
                }
900
                if (!givenChecksum.getValue().equals(computedChecksum.getValue())) {
901
                    logMetacat.error("Given    checksum for " + pid.getValue() + 
902
                        "is " + givenChecksum.getValue());
903
                    logMetacat.error("Computed checksum for " + pid.getValue() + 
904
                        "is " + computedChecksum.getValue());
905
                    String msg = "Computed checksum does not match declared checksum";
906
                    failure = new ServiceFailure("2151", msg);
907
                    setReplicationStatus(thisNodeSession, pid, nodeId, ReplicationStatus.FAILED, failure);
908
                    throw new ServiceFailure("2151", msg);
909
                }
910
            }
911

  
912 886
            // add it to local store
913 887
            Identifier retPid;
914 888
            try {

Also available in: Unified diff