InfoCenter Home > 5.2.2.2.7: The getUserDisplayName and getGroupDisplayName methodsThe getUserDisplayName and getGroupDisplayName methods allow the retrieval of the display name, a descriptive field, associated with the name of a user or group. In the example registry, the annotation field is returned as the display name. WebSphere Application Server expects the methods to throw the EntryNotFoundException exception if the specified user or group name is not found in the registry and to throw the CustomRegistryException exception for any other conditions. The display name is an optional value, so the methods must return NULL when no display name is found for named user or group.
Figure 12 shows the implementation of the getUserDisplayName method for the example registry. The method calls the isValidUser method, described in Figure 7, to verify that the name appears in the registry. If it does not, the method throws the EntryNotFoundException exception. If the user name is valid, the corresponding annotation field is extracted and returned. The getGroupSecurityName method does the same work on the group-information file. public String getUserDisplayName(String userName) throws CustomRegistryException, EntryNotFoundException { String s, displayName = null; BufferedReader in = null; if(!isValidUser(userName)) { EntryNotFoundException nsee = new EntryNotFoundException(userName); throw nsee; } try { in = fileOpen(USERFILENAME); while ((s=in.readLine())!=null) { if (!s.startsWith("#")) { int index = s.indexOf(":"); int index1 = s.lastIndexOf(":"); if ((s.substring(0,index)).equals(userName)) { displayName = s.substring(index1+1); break; } } } } catch(Exception ex) { throw new CustomRegistryException(ex.getMessage()); } finally { fileClose(in); } return displayName; } public String getGroupDisplayName(String userName) throws CustomRegistryException, EntryNotFoundException { String s,displayName = null; BufferedReader in = null; if(!isValidGroup(userName)) { ... } try { in = fileOpen(GROUPFILENAME); ... } catch(Exception ex) { ... } finally { ... } return displayName; } |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|