View Javadoc
1   /*
2    * Licensed under the Apache License, Version 2.0 (the "License");
3    * you may not use this file except in compliance with the License.
4    * You may obtain a copy of the License at
5    *
6    *     http://www.apache.org/licenses/LICENSE-2.0
7    *
8    * Unless required by applicable law or agreed to in writing, software
9    * distributed under the License is distributed on an "AS IS" BASIS,
10   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11   * See the License for the specific language governing permissions and
12   * limitations under the License.
13   */
14  package org.gbif.ws;
15  
16  import java.net.URI;
17  
18  import org.springframework.http.HttpStatus;
19  
20  /**
21   * A HTTP 404 (Not Found) exception.
22   */
23  public class NotFoundException extends WebApplicationException {
24  
25    /**
26     * The URI that cannot be found. Required.
27     */
28    private final URI notFoundUri;
29  
30    /**
31     * Create a HTTP 404 (Not Found) exception.
32     *
33     * @param message     the String that is the entity of the 404 response.
34     * @param notFoundUri the URI that cannot be found.
35     */
36    public NotFoundException(String message, URI notFoundUri) {
37      super(message + " for uri: " + notFoundUri, HttpStatus.NOT_FOUND);
38      this.notFoundUri = notFoundUri;
39    }
40  
41    /**
42     * Get the URI that is not found.
43     */
44    public URI getNotFoundUri() {
45      return notFoundUri;
46    }
47  }