Revision 9068
Added by Jing Tao almost 10 years ago
src/edu/ucsb/nceas/metacat/dataone/MNodeService.java | ||
---|---|---|
505 | 505 |
if (session == null) { |
506 | 506 |
throw new InvalidToken("1110", "Session is required to WRITE to the Node."); |
507 | 507 |
} |
508 |
// verify the pid is valid format |
|
509 |
if (!isValidIdentifier(pid)) { |
|
510 |
throw new InvalidRequest("1102", "The provided identifier is invalid."); |
|
511 |
} |
|
508 | 512 |
// set the submitter to match the certificate |
509 | 513 |
sysmeta.setSubmitter(session.getSubject()); |
510 | 514 |
// set the originating node |
... | ... | |
532 | 536 |
"The supplied system metadata is invalid. " + |
533 | 537 |
"The obsoletedBy field cannot have a value when creating entries."); |
534 | 538 |
} |
539 |
|
|
540 |
// verify the sid in the system metadata |
|
541 |
Identifier sid = sysmeta.getSeriesId(); |
|
542 |
boolean idExists = false; |
|
543 |
if(sid != null) { |
|
544 |
if (!isValidIdentifier(sid)) { |
|
545 |
throw new InvalidSystemMetadata("1180", "The provided series id is invalid."); |
|
546 |
} |
|
547 |
try { |
|
548 |
idExists = IdentifierManager.getInstance().identifierExists(sid.getValue()); |
|
549 |
} catch (SQLException e) { |
|
550 |
throw new ServiceFailure("1190", |
|
551 |
"The series identifier " + sid.getValue() + |
|
552 |
" in the system metadata couldn't be determined if it is unique since : "+e.getMessage()); |
|
553 |
} |
|
554 |
if (idExists) { |
|
555 |
throw new InvalidSystemMetadata("1180", |
|
556 |
"The series identifier " + sid.getValue() + |
|
557 |
" is already used by another object and" + |
|
558 |
"therefore can not be used for this object. Clients should choose" + |
|
559 |
"a new identifier that is unique and retry the operation or " + |
|
560 |
"use CN.reserveIdentifier() to reserve one."); |
|
561 |
|
|
562 |
} |
|
563 |
//the series id equals the pid (new pid hasn't been registered in the system, so IdentifierManager.getInstance().identifierExists method can't exclude this scenario ) |
|
564 |
if(sid.getValue().equals(pid.getValue())) { |
|
565 |
throw new InvalidSystemMetadata("1180", "The series id "+sid.getValue()+" in the system metadata shouldn't have the same value of the pid."); |
|
566 |
} |
|
567 |
} |
|
535 | 568 |
|
536 | 569 |
// call the shared impl |
537 | 570 |
Identifier resultPid = super.create(session, pid, object, sysmeta); |
... | ... | |
591 | 624 |
|
592 | 625 |
// get the referenced object |
593 | 626 |
Identifier pid = sysmeta.getIdentifier(); |
627 |
// verify the pid is valid format |
|
628 |
if (!isValidIdentifier(pid)) { |
|
629 |
throw new InvalidRequest("2153", "The provided identifier in the system metadata is invalid."); |
|
630 |
} |
|
594 | 631 |
|
595 | 632 |
// get from the membernode |
596 | 633 |
// TODO: switch credentials for the server retrieval? |
src/edu/ucsb/nceas/metacat/dataone/CNodeService.java | ||
---|---|---|
1548 | 1548 |
throws InvalidToken, ServiceFailure, NotAuthorized, IdentifierNotUnique, |
1549 | 1549 |
UnsupportedType, InsufficientResources, InvalidSystemMetadata, |
1550 | 1550 |
NotImplemented, InvalidRequest { |
1551 |
|
|
1551 |
|
|
1552 |
// verify the pid is valid format |
|
1553 |
if (!isValidIdentifier(pid)) { |
|
1554 |
throw new InvalidRequest("4891", "The provided identifier is invalid."); |
|
1555 |
} |
|
1552 | 1556 |
// The lock to be used for this identifier |
1553 | 1557 |
Lock lock = null; |
1554 | 1558 |
|
src/edu/ucsb/nceas/metacat/dataone/D1NodeService.java | ||
---|---|---|
338 | 338 |
"permission to WRITE to the Node."); |
339 | 339 |
|
340 | 340 |
} |
341 |
|
|
342 |
// verify the pid is valid format |
|
343 |
if (!isValidIdentifier(pid)) { |
|
344 |
throw new InvalidRequest("1202", "The provided identifier is invalid."); |
|
345 |
} |
|
346 |
|
|
341 |
|
|
347 | 342 |
// verify that pid == SystemMetadata.getIdentifier() |
348 | 343 |
logMetacat.debug("Comparing pid|sysmeta_pid: " + |
349 | 344 |
pid.getValue() + "|" + sysmeta.getIdentifier().getValue()); |
... | ... | |
377 | 372 |
|
378 | 373 |
} |
379 | 374 |
|
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 |
//the series id equals the pid (new pid hasn't been registered in the system, so IdentifierManager.getInstance().identifierExists method can't exclude this scenario ) |
|
403 |
if(sid.getValue().equals(pid.getValue())) { |
|
404 |
throw new InvalidSystemMetadata("1180", "The series id "+sid.getValue()+" in the system metadata shouldn't have the same value of the pid."); |
|
405 |
} |
|
406 |
} |
|
407 | 375 |
|
408 | 376 |
// TODO: this probably needs to be refined more |
409 | 377 |
try { |
Also available in: Unified diff
Moved the rules for the SID from D1NodeService.create to MNodeService.create.
Also moved the code to check the validation of an pid from D1NodeService.create to MNodeService.create, MNodeService.replicate and CNodeService.create.