Project

General

Profile

« Previous | Next » 

Revision 6676

Added by Chris Jones over 12 years ago

Use Subject.equals() when comparing DNs rather than CertificateManager.equalsDN(). Don't lock the pid in isNodeAuthorized() to debug for timeout issues. Minor debugging changes.

View differences:

src/edu/ucsb/nceas/metacat/dataone/CNodeService.java
23 23

  
24 24
package edu.ucsb.nceas.metacat.dataone;
25 25

  
26
import java.io.IOException;
27 26
import java.io.InputStream;
28 27
import java.math.BigInteger;
29 28
import java.util.Calendar;
......
33 32

  
34 33
import javax.servlet.http.HttpServletRequest;
35 34

  
36
import org.apache.commons.io.IOUtils;
37 35
import org.apache.log4j.Logger;
38 36
import org.dataone.client.CNode;
39 37
import org.dataone.client.D1Client;
40
import org.dataone.client.auth.CertificateManager;
41 38
import org.dataone.service.cn.v1.CNAuthorization;
42 39
import org.dataone.service.cn.v1.CNCore;
43 40
import org.dataone.service.cn.v1.CNRead;
......
71 68
import org.dataone.service.types.v1.Session;
72 69
import org.dataone.service.types.v1.Subject;
73 70
import org.dataone.service.types.v1.SystemMetadata;
74
import org.dataone.service.types.v1.util.ChecksumUtil;
75
import org.dataone.service.util.Constants;
76 71

  
77
import com.hazelcast.query.SqlPredicate;
78

  
79 72
import edu.ucsb.nceas.metacat.EventLog;
80 73
import edu.ucsb.nceas.metacat.IdentifierManager;
81
import edu.ucsb.nceas.metacat.McdbDocNotFoundException;
82 74
import edu.ucsb.nceas.metacat.dataone.hazelcast.HazelcastService;
83
import edu.ucsb.nceas.utilities.Log;
84 75

  
85 76
/**
86 77
 * Represents Metacat's implementation of the DataONE Coordinating Node 
......
150 141
          // does the request have the most current system metadata?
151 142
          if ( systemMetadata.getSerialVersion().longValue() != serialVersion ) {
152 143
             String msg = "The requested system metadata version number " + 
153
                 serialVersion + "differs from the current version at " +
144
                 serialVersion + " differs from the current version at " +
154 145
                 systemMetadata.getSerialVersion().longValue() +
155
                 " Please get the latest copy in order to modify it.";
146
                 ". Please get the latest copy in order to modify it.";
156 147
             throw new InvalidRequest("4883", msg);
157 148
          }
158 149
          
......
210 201
      List<Replica> replicas = null;
211 202
      // get the subject
212 203
      Subject subject = session.getSubject();
204
      logMetacat.debug("ReplicationStatus for identifier " + pid.getValue() +
205
          " is " + status.toString());
213 206
      
214 207
      SystemMetadata systemMetadata = null;
215 208
      try {      
......
225 218
          
226 219
          if ( replicas == null || replicas.size() < 1 ) {
227 220
              logMetacat.debug("no replicas to evaluate");
221
              throw new InvalidRequest("4730", "There are no replicas to update.");
228 222
              
229 223
          }
230 224

  
......
260 254
                  
261 255
                  // check if the session subject is in the node subject list
262 256
                  for (Subject nodeSubject : nodeSubjects) {
263
                      if ( CertificateManager.getInstance().equalsDN(
264
                              nodeSubject.getValue(), subject.getValue()) ) {
257
                      if ( nodeSubject.equals(subject) ) {
265 258
                          allowed = true; // subject of session == target node subject
266 259
                          break;
267 260
                          
......
282 275
          // does the request have the most current system metadata?
283 276
          if ( systemMetadata.getSerialVersion().longValue() != serialVersion ) {
284 277
             String msg = "The requested system metadata version number " + 
285
                 serialVersion + "differs from the current version at " +
278
                 serialVersion + " differs from the current version at " +
286 279
                 systemMetadata.getSerialVersion().longValue() +
287
                 " Please get the latest copy in order to modify it.";
280
                 ". Please get the latest copy in order to modify it.";
288 281
             throw new InvalidRequest("4730", msg);
289 282
          }
290 283
          
291
      } catch (Exception e) { // Catch is generic since HZ throws RuntimeException
284
      } catch (RuntimeException e) { // Catch is generic since HZ throws RuntimeException
292 285
        throw new NotFound("4740", "No record found for: " + pid.getValue() +
293 286
            " : " + e.getMessage());
294 287
        
295 288
      }
296 289
          
297 290
      // set the status for the replica
298
      if ( replicaEntryIndex != -1 ) {          
299
          replicas.get(replicaEntryIndex).setReplicationStatus(status);
291
      if ( replicaEntryIndex != -1 ) {
292
          Replica targetReplica = replicas.get(replicaEntryIndex);
293
          targetReplica.setReplicationStatus(status);
294
          logMetacat.debug("Set the replication status for " + 
295
              targetReplica.getReplicaMemberNode().getValue() + " to " +
296
              targetReplica.getReplicationStatus());
300 297
          
298
      } else {
299
          throw new InvalidRequest("4730", "There are no replicas to update.");
300

  
301 301
      }
302
      
303
      systemMetadata.setReplicaList(replicas);
302 304
            
303 305
      // update the metadata
304 306
      try {
......
792 794
          // does the request have the most current system metadata?
793 795
          if ( systemMetadata.getSerialVersion().longValue() != serialVersion ) {
794 796
             String msg = "The requested system metadata version number " + 
795
                 serialVersion + "differs from the current version at " +
797
                 serialVersion + " differs from the current version at " +
796 798
                 systemMetadata.getSerialVersion().longValue() +
797
                 " Please get the latest copy in order to modify it.";
799
                 ". Please get the latest copy in order to modify it.";
798 800
             throw new InvalidRequest("4442", msg);
799 801
          }
800 802
          
......
861 863
            
862 864
            for (Subject nodeSubject : node.getSubjectList()) {
863 865
                
864
                if ( CertificateManager.getInstance().equalsDN(nodeSubject.getValue(), targetNodeSubject.getValue())) {
866
                if ( nodeSubject.equals(targetNodeSubject) ) {
865 867
                    targetNode = node.getIdentifier();
866 868
                    logMetacat.debug("targetNode is : " + targetNode.getValue());
867 869
                    break;
......
878 880
          
879 881
      }
880 882
      //lock, get, and unlock the pid
881
      HazelcastService.getInstance().getSystemMetadataMap().lock(pid);
883
      //HazelcastService.getInstance().getSystemMetadataMap().lock(pid);
882 884
      logMetacat.debug("Getting system metadata for identifier " + pid.getValue());
883 885
      
884 886
      sysmeta = HazelcastService.getInstance().getSystemMetadataMap().get(pid);
......
993 995
              throw new NotAuthorized("1100", msg);
994 996
          }
995 997
          
996
      } catch (Exception e) {
998
      } catch (RuntimeException e) {
997 999
          // Convert Hazelcast runtime exceptions to service failures
998 1000
          String msg = "There was a problem creating the object identified by " +
999 1001
              pid.getValue() + ". There error message was: " + e.getMessage();
1002
          throw new ServiceFailure("4893", msg);
1000 1003
          
1001 1004
      } finally {
1002 1005
          HazelcastService.getInstance().getSystemMetadataMap().unlock(pid);
......
1047 1050
          // does the request have the most current system metadata?
1048 1051
          if ( systemMetadata.getSerialVersion().longValue() != serialVersion ) {
1049 1052
             String msg = "The requested system metadata version number " + 
1050
                 serialVersion + "differs from the current version at " +
1053
                 serialVersion + " differs from the current version at " +
1051 1054
                 systemMetadata.getSerialVersion().longValue() +
1052
                 " Please get the latest copy in order to modify it.";
1055
                 ". Please get the latest copy in order to modify it.";
1053 1056
             throw new InvalidRequest("4402", msg);
1054 1057
          }
1055 1058
          
......
1128 1131
          // does the request have the most current system metadata?
1129 1132
          if ( systemMetadata.getSerialVersion().longValue() != serialVersion ) {
1130 1133
             String msg = "The requested system metadata version number " + 
1131
                 serialVersion + "differs from the current version at " +
1134
                 serialVersion + " differs from the current version at " +
1132 1135
                 systemMetadata.getSerialVersion().longValue() +
1133
                 " Please get the latest copy in order to modify it.";
1136
                 ". Please get the latest copy in order to modify it.";
1134 1137
             throw new InvalidRequest("4853", msg);
1135 1138
          }
1136 1139
          

Also available in: Unified diff