private Contact _getContact(final String userId, final ContactType contactType) { User user = _getUser(userId); if (user != null && contactType != null) { for (Contact eachContact : user.getContacts()) { if (contactType.name().equals(eachContact.getType())) { return eachContact; } } } return null; }
private String _getXMPPAddress(final User user) { if (user == null) return ""; for (final Contact contact : user.getContacts()) { if (contact != null && contact.getType().equals(ContactType.xmppAddress.toString())) { return contact.getInfo().orElse(""); } } return ""; }
private String _getContactInfo(final User user, final ContactType contactType) { return _getContactInfo(user, contactType.name()); }
/** * Get a mobile phone number * * @return String the mobile phone number * @throws java.io.IOException if any. * @param user a {@link org.opennms.netmgt.config.users.User} object. */ public String getMobilePhone(final User user) throws IOException { return getContactInfo(user, ContactType.mobilePhone.toString()); }
/** * Get a numeric pin * * @param userID * the user ID of the user to return * @return String the numeric pin * @throws java.io.IOException if any. */ public String getNumericPin(final String userID) throws IOException { return getContactInfo(userID, ContactType.numericPage.toString()); }
/** * Get a pager email by user * * @param user a {@link org.opennms.netmgt.config.users.User} object. * @return String the pager email * @throws java.io.IOException if any. */ public String getPagerEmail(final User user) throws IOException { return getContactInfo(user, ContactType.pagerEmail.toString()); }
/** * Get a pager email by name * * @param userID * the user ID of the user to return * @return String the pager email * @throws java.io.IOException if any. */ public String getPagerEmail(final String userID) throws IOException { return getContactInfo(userID, ContactType.pagerEmail.toString()); }
/** * @see {@link #getContactInfo(String, String)} */ public String getContactInfo(final String userId, final ContactType contactType) throws IOException { if (userId == null || contactType == null) return null; return getContactInfo(userId, contactType.name()); }
/** * Get a home phone number * * @return String the home phone number * @throws java.io.IOException if any. * @param user a {@link org.opennms.netmgt.config.users.User} object. */ public String getHomePhone(final User user) throws IOException { return getContactInfo(user, ContactType.homePhone.toString()); }
/** * Get a Text Page Service Provider * * @param userID * the user ID of the user to return * @return String the text page service provider. * @throws java.io.IOException if any. */ public String getTextPage(final String userID) throws IOException { return getContactServiceProvider(userID, ContactType.textPage.toString()); }
/** * Get a text pin * * @return String the text pin * @param user a {@link org.opennms.netmgt.config.users.User} object. * @throws java.io.IOException if any. */ public String getTextPin(final User user) throws IOException { return getContactInfo(user, ContactType.textPage.toString()); }
/** * Get a text pin * * @param userID * the user ID of the user to return * @return String the text pin * @throws java.io.IOException if any. */ public String getTextPin(final String userID) throws IOException { return getContactInfo(userID, ContactType.textPage.toString()); }
/** * Get a email by name * * @param userID * the user ID of the user to return * @return String the email specified by name * @throws java.io.IOException if any. */ public String getEmail(final String userID) throws IOException { return getContactInfo(userID, ContactType.email.toString()); }
/** * Get a mobile phone number * * @param userID * the user ID of the user to return * @return String the mobile phone number * @throws java.io.IOException if any. */ public String getMobilePhone(final String userID) throws IOException { return getContactInfo(userID, ContactType.mobilePhone.toString()); }
/** * Get a work phone number * * @param userID * the user ID of the user to return * @return String the work phone number * @throws java.io.IOException if any. */ public String getWorkPhone(final String userID) throws IOException { return getContactInfo(userID, ContactType.workPhone.toString()); }
/** * Get a Text Page Service Provider * * @return String the text page service provider. * @param user a {@link org.opennms.netmgt.config.users.User} object. * @throws java.io.IOException if any. */ public String getTextPage(final User user) throws IOException { return getContactServiceProvider(user, ContactType.textPage.toString()); }
/** * Get a numeric service provider * * @return String the service provider * @param user a {@link org.opennms.netmgt.config.users.User} object. * @throws java.io.IOException if any. */ public String getNumericPage(final User user) throws IOException { return getContactServiceProvider(user, ContactType.numericPage.toString()); }
/** * Get a user's microblog username by username * * @param name * the username of the user whose microblog username should be returned * @return the microblog username of the specified user * @throws java.io.IOException if any. * @throws java.io.FileNotFoundException if any. */ public String getMicroblogName(final String name) throws FileNotFoundException, IOException { return getContactInfo(name, ContactType.microblog.toString()); }
private void _setContact(final User user, final ContactType contactType, final String value) { if (user != null && !StringUtils.isEmpty(value)) { Contact contact = _getContact(user.getUserId(), contactType); if (contact == null) { contact = new Contact(); user.addContact(contact); } contact.setInfo(value); contact.setType(contactType.name()); } }
/** * Get a home phone number * * @param userID * the user ID of the user to return * @return String the home phone number * @throws java.io.IOException if any. */ public String getHomePhone(final String userID) throws IOException { return getContactInfo(userID, ContactType.homePhone.toString()); }