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.user;
17:
18: import java.util.Map;
19: import java.util.HashMap;
20:
21: public class UserNotFoundException extends UserManagementException {
22: private long id;
23: private String name;
24:
25: private static final String ID_KEY = "id";
26: private static final String NAME_KEY = "name";
27:
28: public UserNotFoundException(long id) {
29: this .id = id;
30: }
31:
32: public UserNotFoundException(String login) {
33: this .name = login;
34: }
35:
36: public UserNotFoundException(Map params) {
37: if (params.containsKey(ID_KEY)) {
38: this .id = Long.parseLong((String) params.get(ID_KEY));
39: } else {
40: this .name = (String) params.get(NAME_KEY);
41: }
42: }
43:
44: public Map<String, String> getState() {
45: Map<String, String> map = new HashMap<String, String>(1);
46: if (name == null)
47: map.put(ID_KEY, String.valueOf(id));
48: else
49: map.put(NAME_KEY, name);
50: return map;
51: }
52:
53: public String getMessage() {
54: if (name != null)
55: return "The user with login \"" + name
56: + "\" does not exist";
57: else
58: return "The user with ID " + id + " does not exist.";
59: }
60: }
|