Project

General

Profile

« Previous | Next » 

Revision 6862

update authoritative member node id when we change it (reconfiguration) and when we initially register as a MN with the CN.

View differences:

D1Admin.java
26 26

  
27 27
package edu.ucsb.nceas.metacat.admin;
28 28

  
29
import java.io.File;
30 29
import java.util.Vector;
31 30

  
32 31
import javax.servlet.http.HttpServletRequest;
......
37 36
import org.dataone.client.D1Client;
38 37
import org.dataone.client.auth.CertificateManager;
39 38
import org.dataone.service.exceptions.BaseException;
40
import org.dataone.service.exceptions.IdentifierNotUnique;
41
import org.dataone.service.exceptions.InvalidRequest;
42
import org.dataone.service.exceptions.InvalidToken;
43
import org.dataone.service.exceptions.NotAuthorized;
44
import org.dataone.service.exceptions.NotFound;
45
import org.dataone.service.exceptions.NotImplemented;
46
import org.dataone.service.exceptions.ServiceFailure;
47 39
import org.dataone.service.types.v1.Node;
48 40
import org.dataone.service.types.v1.NodeList;
49 41
import org.dataone.service.types.v1.NodeReference;
50 42
import org.dataone.service.types.v1.Session;
51 43

  
44
import edu.ucsb.nceas.metacat.IdentifierManager;
52 45
import edu.ucsb.nceas.metacat.dataone.MNodeService;
53 46
import edu.ucsb.nceas.metacat.properties.PropertyService;
54 47
import edu.ucsb.nceas.metacat.shared.MetacatUtilException;
55 48
import edu.ucsb.nceas.metacat.util.RequestUtil;
56
import edu.ucsb.nceas.metacat.util.SystemUtil;
57
import edu.ucsb.nceas.utilities.FileUtil;
58 49
import edu.ucsb.nceas.utilities.GeneralPropertyException;
59 50
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
60 51

  
......
257 248
					
258 249
					PropertyService.setPropertyNoPersist("dataone.nodeName", nodeName);
259 250
					PropertyService.setPropertyNoPersist("dataone.nodeDescription", nodeDescription);
251
					
252
					// check if we have updated the memberNodeId
253
					String existingMemberNodeId = PropertyService.getProperty("dataone.memberNodeId");
254
					if (!existingMemberNodeId.equals(memberNodeId)) {
255
						// update all existing system Metadata for this node id
256
						IdentifierManager.getInstance().updateAuthoritativeMemberNodeId(existingMemberNodeId, memberNodeId);
257
					}
258
					// TODO: persist in DB?
260 259
					PropertyService.setPropertyNoPersist("dataone.memberNodeId", memberNodeId);
260
					
261 261
					PropertyService.setPropertyNoPersist("dataone.nodeSynchronize", Boolean.toString(synchronize));
262 262
					PropertyService.setPropertyNoPersist("dataone.nodeReplicate", Boolean.toString(replicate));
263 263
					PropertyService.setPropertyNoPersist("dataone.subject", subject);
......
319 319
			}
320 320
		}
321 321
	}
322
	
322

  
323 323
	/**
324 324
	 * Register as a member node on the DataONE network.  The node description is
325 325
	 * retrieved from the getCapabilities() service, and so this should only be called
......
352 352
            } else {
353 353
	            logMetacat.debug("Registering node with DataONE. " + cn.getNodeBaseServiceUrl());
354 354
	            NodeReference mnodeRef = cn.register(session, node);
355
	            
356
	            String memberNodeId = mnodeRef.getValue();
357
	            String existingMemberNodeId = PropertyService.getProperty("dataone.memberNodeId");
358
				if (!existingMemberNodeId.equals(memberNodeId)) {
359
					// update all existing system Metadata for this node id
360
					IdentifierManager.getInstance().updateAuthoritativeMemberNodeId(existingMemberNodeId, memberNodeId);
361
				}
355 362
	            // save this assigned node id
356
	            PropertyService.setProperty("dataone.memberNodeId", mnodeRef.getValue());
363
	            PropertyService.setProperty("dataone.memberNodeId", memberNodeId);
357 364
	            
358 365
            }
359 366
        } catch (BaseException e) {

Also available in: Unified diff