Exemple #1
0
  private InternetAddress createAddressFromViewpoint(
      UserViewpoint viewpoint, SpecialSender fallbackAddress) {
    PersonView fromViewedBySelf =
        personViewer.getPersonView(viewpoint, viewpoint.getViewer(), PersonViewExtra.PRIMARY_EMAIL);

    InternetAddress internetAddress;

    try {
      if ((fromViewedBySelf.getEmail() != null)
          && (fromViewedBySelf.getEmail().getEmail() != null)) {
        String niceName = fromViewedBySelf.getName();
        String address = fromViewedBySelf.getEmail().getEmail();
        internetAddress = new InternetAddress(address, niceName);
      } else {
        // theoretically, we might have users in the system who do not have an e-mail, but
        // have an AIM, when we allow such users in practice, we can change this to possibly
        // use users's @aol.com address, though it's quite possible that the person does not
        // really use this address
        internetAddress = new InternetAddress(fallbackAddress.toString());
      }
    } catch (AddressException e) {
      throw new RuntimeException(e);
    } catch (UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }

    return internetAddress;
  }
 protected PersonView getData1UserView(Viewpoint viewpoint, Block block) {
   User user = getData1User(block);
   // No PersonViewExtra are needed since we know this isn't a contact so we have a name
   // without having to get any resources.
   PersonView userView = personViewer.getPersonView(viewpoint, user);
   return userView;
 }
Exemple #3
0
  public void sendGroupMembershipChange(User recipient, GroupMember groupMember) {
    // Short-circuit message creation
    if (!userIsPresent(recipient.getGuid())) return;

    Viewpoint viewpoint = new UserViewpoint(recipient);

    PersonView memberView =
        personViewer.getPersonView(
            viewpoint, groupMember.getMember(), PersonViewExtra.PRIMARY_RESOURCE);

    GroupView groupView = groupSystem.getGroupView(viewpoint, groupMember.getGroup());

    Message message = new Message();
    message.setType(Message.Type.normal);
    addMembershipChangeExtension(message, groupView, groupMember, memberView);

    sendMessage(recipient.getGuid(), message);
  }