コード例 #1
0
ファイル: MailerBean.java プロジェクト: nihed/magnetism
  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;
  }
コード例 #2
0
ファイル: MessageSender.java プロジェクト: nihed/magnetism
  private void addMembershipChangeExtension(
      Message message, GroupView groupView, GroupMember member, PersonView memberView) {
    XmlBuilder builder = new XmlBuilder();
    builder.openElement(
        MEMBERSHIP_CHANGE_ELEMENT_NAME,
        "xmlns",
        MEMBERSHIP_CHANGE_NAMESPACE,
        "membershipStatus",
        member.getStatus().toString(),
        "groupId",
        groupView.getIdentifyingGuid().toString(),
        "userId",
        memberView.getIdentifyingGuid().toString());
    memberView.writeToXmlBuilderOld(builder);
    groupView.writeToXmlBuilderOld(builder);
    builder.closeElement();

    message.getElement().add(elementFromXml(builder.toString()));
  }