1 16 package org.outerj.daisy.repository.user; 17 18 import java.util.Map ; 19 import java.util.HashMap ; 20 21 public class RoleNotFoundException 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 RoleNotFoundException(long id) { 29 this.id = id; 30 } 31 32 public RoleNotFoundException(String name) { 33 this.name = name; 34 } 35 36 public RoleNotFoundException(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 getState() { 45 HashMap map = new HashMap (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 role named \"" + name + "\" does not exist"; 56 else 57 return "The role with ID " + id + " does not exist."; 58 } 59 } 60 | Popular Tags |