Project

General

Profile

« Previous | Next » 

Revision 9045

Added by Jing Tao almost 10 years ago

Add the enforcement for the sid in the create method.

View differences:

src/edu/ucsb/nceas/metacat/dataone/D1NodeService.java
355 355
            sysmeta.getIdentifier().getValue() + ".");
356 356
        
357 357
    }
358
    
358 359

  
359 360
    logMetacat.debug("Checking if identifier exists: " + pid.getValue());
360 361
    // Check that the identifier does not already exist
......
376 377
    	
377 378
    }
378 379
    
380
    // verify the sid in the system metadata
381
    Identifier sid = sysmeta.getSeriesId();
382
    if(sid != null) {
383
        if (!isValidIdentifier(sid)) {
384
            throw new InvalidSystemMetadata("1180", "The provided series id is invalid.");
385
        }
386
        try {
387
            idExists = IdentifierManager.getInstance().identifierExists(sid.getValue());
388
        } catch (SQLException e) {
389
            throw new ServiceFailure("1190", 
390
                                    "The series identifier " + sid.getValue() +
391
                                    " in the system metadata couldn't be determined if it is unique since : "+e.getMessage());
392
        }
393
        if (idExists) {
394
                throw new InvalidSystemMetadata("1180", 
395
                          "The series identifier " + sid.getValue() +
396
                          " is already used by another object and" +
397
                          "therefore can not be used for this object. Clients should choose" +
398
                          "a new identifier that is unique and retry the operation or " +
399
                          "use CN.reserveIdentifier() to reserve one.");
400
            
401
        }
402
    }
403
    
379 404
    // TODO: this probably needs to be refined more
380 405
    try {
381 406
      allowed = isAuthorized(session, pid, Permission.WRITE);

Also available in: Unified diff