01: /*
02: * Copyright 2004 Outerthought bvba and Schaubroeck nv
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.outerj.daisy.repository;
17:
18: import java.util.Map;
19: import java.util.HashMap;
20: import java.util.Locale;
21: import java.util.ResourceBundle;
22: import java.text.MessageFormat;
23:
24: public class DocumentNotFoundException extends RepositoryException
25: implements LocalizedException {
26: private String id;
27:
28: private static final String ID_KEY = "id";
29:
30: public DocumentNotFoundException(String id) {
31: this .id = id;
32: }
33:
34: public DocumentNotFoundException(String id, Throwable cause) {
35: super (cause);
36: this .id = id;
37: }
38:
39: public DocumentNotFoundException(Map params) {
40: this .id = (String) params.get(ID_KEY);
41: }
42:
43: public Map<String, String> getState() {
44: Map<String, String> map = new HashMap<String, String>(1);
45: map.put(ID_KEY, id);
46: return map;
47: }
48:
49: public String getMessage() {
50: return getMessage(Locale.US);
51: }
52:
53: public String getMessage(Locale locale) {
54: ResourceBundle bundle = ResourceBundle.getBundle(
55: "org/outerj/daisy/repository/messages", locale);
56: String message = bundle
57: .getString("document-not-found-exception");
58: return MessageFormat.format(message, id);
59: }
60: }
|