This project has retired. For details please refer to its Attic page.
RedbackServiceException xref
View Javadoc

1   package org.apache.archiva.redback.rest.api.services;
2   /*
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   */
20  
21  import org.apache.archiva.redback.rest.api.model.ErrorMessage;
22  
23  import java.util.ArrayList;
24  import java.util.List;
25  
26  /**
27   * @author Olivier Lamy
28   * @since 1.3
29   */
30  public class RedbackServiceException
31      extends Exception
32  {
33      private int httpErrorCode = 500;
34  
35      private List<ErrorMessage> errorMessages = new ArrayList<ErrorMessage>(0);
36  
37      public RedbackServiceException( String s )
38      {
39          super( s );
40      }
41  
42      public RedbackServiceException( String s, int httpErrorCode )
43      {
44          super( s );
45          this.httpErrorCode = httpErrorCode;
46      }
47  
48      public RedbackServiceException( ErrorMessage errorMessage )
49      {
50          errorMessages.add( errorMessage );
51      }
52  
53      public RedbackServiceException( ErrorMessage errorMessage, int httpErrorCode )
54      {
55          this.httpErrorCode = httpErrorCode;
56          errorMessages.add( errorMessage );
57      }
58  
59      public RedbackServiceException( List<ErrorMessage> errorMessage )
60      {
61          errorMessages.addAll( errorMessage );
62      }
63  
64      public int getHttpErrorCode()
65      {
66          return httpErrorCode;
67      }
68  
69      public void setHttpErrorCode( int httpErrorCode )
70      {
71          this.httpErrorCode = httpErrorCode;
72      }
73  
74      public List<ErrorMessage> getErrorMessages()
75      {
76          if ( errorMessages == null )
77          {
78              this.errorMessages = new ArrayList<ErrorMessage>();
79          }
80          return errorMessages;
81      }
82  
83      public void setErrorMessages( List<ErrorMessage> errorMessages )
84      {
85          this.errorMessages = errorMessages;
86      }
87  
88      public void addErrorMessage( ErrorMessage errorMessage )
89      {
90          this.errorMessages.add( errorMessage );
91      }
92  }