Project

General

Profile

« Previous | Next » 

Revision 6222

implement resolve() method

View differences:

src/edu/ucsb/nceas/metacat/dataone/CNodeService.java
52 52
import org.dataone.service.types.ObjectFormatIdentifier;
53 53
import org.dataone.service.types.ObjectFormatList;
54 54
import org.dataone.service.types.ObjectList;
55
import org.dataone.service.types.ObjectLocation;
55 56
import org.dataone.service.types.ObjectLocationList;
56 57
import org.dataone.service.types.Permission;
57 58
import org.dataone.service.types.QueryType;
......
371 372
	  throws InvalidRequest, InvalidToken, ServiceFailure, NotAuthorized,
372 373
	  NotFound, NotImplemented {
373 374

  
374
		return null;
375
		ObjectLocationList objLocList = new ObjectLocationList();
376
		objLocList.setIdentifier(pid);
377
		
378
		// get the system metadata
379
		String guid = pid.getValue();
380
		
381
		// are we allowed to do this?
382
		if (!hasPermission(session, pid, Permission.READ)) {
383
			throw new NotAuthorized("4720", Permission.READ + " not allowed on " + guid);	
384
		}
385
		
386
		SystemMetadata systemMetadata = null;
387
		try {
388
			systemMetadata = IdentifierManager.getInstance().getSystemMetadata(guid);
389
		} catch (McdbDocNotFoundException e) {
390
			throw new NotFound("4740", "No record found for: " + guid);
391
		}
392
			
393
		NodeList nodes = listNodes();
394
		
395
		// get the locations
396
		List<Replica> replicas = systemMetadata.getReplicaList();
397
		for (Replica replica: replicas) {
398
			NodeReference nodeReference = replica.getReplicaMemberNode();
399
			ObjectLocation objectLocation = new ObjectLocation();
400
			objectLocation.setNodeIdentifier(nodeReference);
401
			// get the node
402
			Node node = null;
403
			for (Node n: nodes.getNodeList()) {
404
				if (n.getIdentifier().equals(nodeReference)) {
405
					node = n;
406
					break;
407
				}
408
			}
409
			objectLocation.setBaseURL(node.getBaseURL());
410
			// TODO set URL
411
			// TODO set preference
412
			objLocList.addObjectLocation(objectLocation);
413
		}
414
		
415
		return objLocList;
375 416
	}
376 417

  
377 418
	/**

Also available in: Unified diff