Project

General

Profile

« Previous | Next » 

Revision 9481

Added by Jing Tao almost 9 years ago

Use the ServiceFailure to replace the InvalidRequest when it is the read-only mode (CN throws the exception).

View differences:

src/edu/ucsb/nceas/metacat/ReadOnlyChecker.java
32 32
 */
33 33
public class ReadOnlyChecker {
34 34
    
35

  
35
    public static final String DATAONEERROR= "The Metacat member node is on the read-only mode and your request can't be fulfiled. Please try again later.";
36 36
    /**
37 37
     * Default constructor
38 38
     */
src/edu/ucsb/nceas/metacat/dataone/MNodeService.java
254 254
        throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, NotImplemented {
255 255

  
256 256
        if(isReadOnlyMode()) {
257
            throw new ServiceFailure("2902", "The Metacat member node is on the read-only mode and your request can't be fulfiled. Please try again later.");
257
            throw new ServiceFailure("2902", ReadOnlyChecker.DATAONEERROR);
258 258
        }
259 259
    	// only admin of  the MN or the CN is allowed a full delete
260 260
        boolean allowed = false;
......
311 311
        InvalidSystemMetadata, NotImplemented, InvalidRequest {
312 312
        
313 313
        if(isReadOnlyMode()) {
314
            throw new InvalidRequest("1202", "The Metacat member node is on the read-only mode and your request can't be fulfiled. Please try again later.");
314
            throw new ServiceFailure("1310", ReadOnlyChecker.DATAONEERROR);
315 315
        }
316 316

  
317 317
        //transform a sid to a pid if it is applicable
......
536 536
            IdentifierNotUnique, UnsupportedType, InsufficientResources, InvalidSystemMetadata, NotImplemented, InvalidRequest {
537 537

  
538 538
        if(isReadOnlyMode()) {
539
            throw new InvalidRequest("1102", "The Metacat member node is on the read-only mode and your request can't be fulfiled. Please try again later.");
539
            throw new ServiceFailure("1190", ReadOnlyChecker.DATAONEERROR);
540 540
        }
541 541
        // check for null session
542 542
        if (session == null) {
......
2479 2479
	  public Identifier archive(Session session, Identifier pid) 
2480 2480
	      throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, NotImplemented {
2481 2481
	      if(isReadOnlyMode()) {
2482
	            throw new ServiceFailure("2912", "The Metacat member node is on the read-only mode and your request can't be fulfiled. Please try again later.");
2482
	            throw new ServiceFailure("2912", ReadOnlyChecker.DATAONEERROR);
2483 2483
	        }
2484 2484
	      boolean allowed = false;
2485 2485
	      // do we have a valid pid?
......
2529 2529
            ServiceFailure, InvalidRequest, InvalidSystemMetadata, InvalidToken {
2530 2530
	  
2531 2531
	  if(isReadOnlyMode()) {
2532
            throw new InvalidRequest("4869", "The Metacat member node is on the read-only mode and your request can't be fulfiled. Please try again later.");
2532
            throw new ServiceFailure("4868",  ReadOnlyChecker.DATAONEERROR);
2533 2533
      }
2534 2534
	 if(sysmeta == null) {
2535 2535
	     throw  new InvalidRequest("4869", "The system metadata object should NOT be null in the updateSystemMetadata request.");
src/edu/ucsb/nceas/metacat/restservice/v1/MNResourceHandler.java
646 646
        ReadOnlyChecker checker = new ReadOnlyChecker();
647 647
        boolean isReadOnlyMode = checker.isReadOnly();
648 648
        if(isReadOnlyMode) {
649
            throw new InvalidRequest("1334", "The Metacat member node is on the read-only mode and your request can't be fulfiled. Please try again later.");
649
            throw new ServiceFailure("1333", ReadOnlyChecker.DATAONEERROR);
650 650
        }
651 651
        long serialVersion = 0L;
652 652
        String serialVersionStr = null;
......
863 863
        ReadOnlyChecker checker = new ReadOnlyChecker();
864 864
        boolean isReadOnlyMode = checker.isReadOnly();
865 865
        if(isReadOnlyMode) {
866
            throw new InvalidRequest("2153", "The Metacat member node is on the read-only mode and your request can't be fulfiled. Please try again later.");
866
            throw new ServiceFailure("2151", ReadOnlyChecker.DATAONEERROR);
867 867
        }
868 868
        
869 869
        // somewhat unorthodox, but the call is asynchronous and we'd like to return this info sooner
src/edu/ucsb/nceas/metacat/restservice/v2/MNResourceHandler.java
674 674
        ReadOnlyChecker checker = new ReadOnlyChecker();
675 675
        boolean isReadOnlyMode = checker.isReadOnly();
676 676
        if(isReadOnlyMode) {
677
            throw new InvalidRequest("1334", "The Metacat member node is on the read-only mode and your request can't be fulfiled. Please try again later.");
677
            throw new ServiceFailure("1333", ReadOnlyChecker.DATAONEERROR);
678 678
        }
679 679
        
680 680
        //final long serialVersion = 0L;
......
976 976
        ReadOnlyChecker checker = new ReadOnlyChecker();
977 977
        boolean isReadOnlyMode = checker.isReadOnly();
978 978
        if(isReadOnlyMode) {
979
            throw new InvalidRequest("2153", "The Metacat member node is on the read-only mode and your request can't be fulfiled. Please try again later.");
979
            throw new ServiceFailure("2151", ReadOnlyChecker.DATAONEERROR);
980 980
        }
981 981
        
982 982
        // somewhat unorthodox, but the call is asynchronous and we'd like to return this info sooner

Also available in: Unified diff