当前位置: 首页>>代码示例>>Java>>正文


Java User.getEmail方法代码示例

本文整理汇总了Java中org.sakaiproject.user.api.User.getEmail方法的典型用法代码示例。如果您正苦于以下问题:Java User.getEmail方法的具体用法?Java User.getEmail怎么用?Java User.getEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.sakaiproject.user.api.User的用法示例。


在下文中一共展示了User.getEmail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getUser

import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
public org.sakaiproject.kaltura.logic.User getUser(String userId) {
    org.sakaiproject.kaltura.logic.User user = null;
    if (userId != null) {
        User u = null;
        try {
            u = userDirectoryService.getUserByEid(userId);
        } catch (UserNotDefinedException e) {
            try {
                u = userDirectoryService.getUser(userId);
            } catch (UserNotDefinedException e1) {
                log.warn("Cannot get user for id: " + userId);
            }
        }
        if (u != null) {
            user = new org.sakaiproject.kaltura.logic.User(u.getId(),
                    u.getEid(), u.getDisplayName(), u.getSortName(), u.getEmail());
            user.fname = u.getFirstName();
            user.lname = u.getLastName();
        }
    }
    return user;
}
 
开发者ID:ITYug,项目名称:kaltura-ce-sakai-extension,代码行数:23,代码来源:SakaiExternalLogicImpl.java

示例2: getUserEmail

import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
/**
 * Gets the email address for a given user
 * <p/>
 * Differs from original above as that one uses the session to get the email address hence you must know this in advance or be logged in to the web services
 * with that user. This uses a userid as well so we could be logged in as admin and retrieve the email address for any user.
 *
 * @param sessionid the id of a valid session
 * @param userid    the login username (ie jsmith26) of the user you want the email address for
 * @return the email address for the user
 * @throws RuntimeException
 */
@WebMethod
@Path("/getUserEmail")
@Produces("text/plain")
@GET
public String getUserEmail(
        @WebParam(name = "sessionid", partName = "sessionid") @QueryParam("sessionid") String sessionid,
        @WebParam(name = "userid", partName = "userid") @QueryParam("userid") String userid) {
    Session session = establishSession(sessionid);
    try {
        User user = userDirectoryService.getUserByEid(userid);
        return user.getEmail();
    } catch (Exception e) {
        log.error("WS getUserEmail() failed for user: " + userid + " : " + e.getClass().getName() + " : " + e.getMessage());
        return "";
    }
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:28,代码来源:SakaiScript.java

示例3: notifyCourseRequestRequester

import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
public void notifyCourseRequestRequester(String requestEmail, String supportEmailContent, String termTitle)
{
	User currentUser = userDirectoryService.getCurrentUser();
	String currentUserDisplayName = currentUser!=null?currentUser.getDisplayName():"";
	String currentUserDisplayId = currentUser!=null?currentUser.getDisplayId():"";
	String currentUserEmail = currentUser!=null?currentUser.getEmail():"";
	
	String from = requestEmail;
	String to = currentUserEmail;
	String headerTo = to;
	String replyTo = to;
	Map<String, String> replacementValues = new HashMap<>();
	replacementValues.put("currentUserDisplayName", currentUserDisplayName);
	replacementValues.put("currentUserDisplayId", currentUserDisplayId);
	replacementValues.put("currentUserEmail", currentUserEmail);
	replacementValues.put("termTitle", termTitle);
	replacementValues.put("supportEmailContent", supportEmailContent);
	replacementValues.put("requestEmail", requestEmail);
	
	emailTemplateServiceSend(NOTIFY_COURSE_REQUEST_REQUESTER, (new ResourceLoader()).getLocale(), currentUser, from, to, headerTo, replyTo, replacementValues);
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:22,代码来源:ETSUserNotificationProviderImpl.java

示例4: EntityUser

import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
/**
 * Construct an EntityUser from a legacy user object
 * @param user a legacy user or user edit
 */
public EntityUser(User user) {
    this.user = user;
    this.id = user.getId();
    this.eid = user.getEid();
    this.email = user.getEmail();
    this.firstName = user.getFirstName();
    this.lastName = user.getLastName();
    this.displayName = user.getDisplayName();
    this.displayId = user.getDisplayId();
    this.owner = user.getCreatedBy() == null ? null : "/user/" + user.getCreatedBy().getId();
    this.lastModified = user.getModifiedTime() == null ? System.currentTimeMillis() : user.getModifiedTime().getTime();
    this.type = user.getType();
    ResourceProperties rp = user.getProperties();
    for (Iterator<String> iterator = rp.getPropertyNames(); iterator.hasNext();) {
        String name = iterator.next();
        String value = rp.getProperty(name);
        this.setProperty(name, value);
    }
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:24,代码来源:EntityUser.java

示例5: getSiteUpdaters

import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
/**
 *  Returns a map of display name onto user id for each user, in the
 *  specified site, with site.upd. If a user doesn't have an email specced,
 *  they aren't returned.
 *
 *  @param siteId The site to retrieve updaters for
 *  @return A map of display name onto user id
 */
public Map<String, String> getSiteUpdaters(String siteId) {

    try {
        Site site = siteService.getSite(siteId);
        Map<String, String> map = new HashMap<String, String>();
        Set<String> userIds = site.getUsersIsAllowed(SiteService.SECURE_UPDATE_SITE);
        Set<String> hiddenUserIds = privacyManager.findHidden("/site/" + siteId, userIds);
        userIds.removeAll(hiddenUserIds);
        List<User> users = userDirectoryService.getUsers(userIds);
        for (User user : users) {
            String email = user.getEmail();
            if (email != null && email.length() > 0) {
                map.put(user.getId(), user.getDisplayName());
            }
        }
        return map;
    } catch (Exception e) {
        log.error("Failed to get site updaters for site : " + siteId + ". Returning an empty map ...");
        return new HashMap<String, String>();
    }
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:30,代码来源:SakaiProxy.java

示例6: getUserEmailForCurrentUser

import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
/**
 * Get a user's email address based on their session id
 *
 * @param sessionid the session id of the user who's email address you wish to retrieve
 * @return the email address for the user
 * @throws RuntimeException
 */
@WebMethod
@Path("/getUserEmailForCurrentUser")
@Produces("text/plain")
@GET
public String getUserEmailForCurrentUser(
        @WebParam(name = "sessionid", partName = "sessionid") @QueryParam("sessionid") String sessionid) {
    Session session = establishSession(sessionid);
    User user = userDirectoryService.getCurrentUser();
    return user.getEmail();
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:18,代码来源:SakaiScript.java

示例7: notifyCourseRequestRequester

import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public void notifyCourseRequestRequester(String requestEmail, String supportEmailContent, String termTitle)
{
	User currentUser = userDirectoryService.getCurrentUser();
	String currentUserDisplayName = currentUser!=null?currentUser.getDisplayName():"";
	String currentUserDisplayId = currentUser!=null?currentUser.getDisplayId():"";
	String currentUserId = currentUser!=null?currentUser.getId():"";
	String currentUserEmail = currentUser!=null?currentUser.getEmail():"";
	

	ResourceLoader rb = new ResourceLoader(currentUserId, "UserNotificationProvider");
	
	String from = requestEmail;
	String to = currentUserEmail;
	String headerTo = to;
	String replyTo = to;
	// message subject
	String message_subject = rb.getString("java.sitereqfrom") + " " + currentUserDisplayName + " " + rb.getString("java.for") + " " + termTitle;
	
	StringBuffer buf = new StringBuffer();
	buf.append(rb.getString("java.isbeing") + " ");
	buf.append(rb.getString("java.meantime") + "\n\n");
	buf.append(rb.getString("java.copy") + "\n\n");
	buf.append(supportEmailContent);
	buf.append("\n" + rb.getString("java.wish") + " " + requestEmail);
	emailService.send(from, to, message_subject, buf.toString(), headerTo, replyTo, null);
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:30,代码来源:UserNotificationProviderImpl.java

示例8: getCurrentUserEmailAddress

import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
private String getCurrentUserEmailAddress() {
	User currentUser = userDirectoryService.getCurrentUser();
	String email = currentUser != null ? currentUser.getEmail():null;
	if (email == null || email.length() == 0) {
		email = getSetupRequestEmailAddress();
	}
	return email;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:9,代码来源:UserNotificationProviderImpl.java

示例9: notifyAddedParticipant

import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
public void notifyAddedParticipant(boolean newNonOfficialAccount,
		User user, Site site) {
	
	String from = serverConfigurationService.getBoolean(NOTIFY_FROM_CURRENT_USER, false)?
			getCurrentUserEmailAddress():getSetupRequestEmailAddress();
	//we need to get the template

	if (from != null) {
		String productionSiteName = serverConfigurationService.getString(
				"ui.service", "");
		String emailId = user.getEmail();
		String to = emailId;
		String headerTo = emailId;
		String replyTo = from;
		Map<String, String> rv = new HashMap<>();
		rv.put("productionSiteName", productionSiteName);

		Map<String, String> replacementValues = new HashMap<>();
		replacementValues.put("userName", user.getDisplayName());
		replacementValues.put("userEid", user.getEid());
		replacementValues.put("localSakaiName", productionSiteName);
		replacementValues.put("currentUserName",userDirectoryService.getCurrentUser().getDisplayName());
		replacementValues.put("localSakaiUrl", serverConfigurationService.getPortalUrl());
		String nonOfficialAccountUrl = serverConfigurationService.getString("nonOfficialAccount.url", null);
		replacementValues.put("hasNonOfficialAccountUrl", nonOfficialAccountUrl!=null?Boolean.TRUE.toString().toLowerCase():Boolean.FALSE.toString().toLowerCase());
		replacementValues.put("nonOfficialAccountUrl",nonOfficialAccountUrl);
		replacementValues.put("siteName", site.getTitle());
		replacementValues.put("productionSiteName", productionSiteName);
		replacementValues.put("newNonOfficialAccount", Boolean.toString(newNonOfficialAccount).toLowerCase());
		replacementValues.put("xloginText", serverConfigurationService.getString("xlogin.text", "Login"));
		replacementValues.put("loginText", serverConfigurationService.getString("login.text", "Login"));
		replacementValues.put("siteUrl", site.getUrl());
		
		// send email
		emailTemplateServiceSend(NOTIFY_ADDED_PARTICIPANT, null, user, from, to, headerTo, replyTo, replacementValues);
	} // if
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:38,代码来源:ETSUserNotificationProviderImpl.java

示例10: getCurrentUserFields

import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
protected Map<String, String> getCurrentUserFields() {
   Map<String, String> rv = new HashMap<>();
   String userRef = developerHelperService.getCurrentUserReference();
   if (userRef != null) {
      User user = (User) developerHelperService.fetchEntity(userRef);
      try {
         String email = user.getEmail();
         if (email == null)
            email = "";
         String first = user.getFirstName();
         if (first == null)
            first = "";
         String last = user.getLastName();
         if (last == null)
            last ="";

         rv.put(CURRENT_USER_EMAIL, email);
         rv.put(CURRENT_USER_FIRST_NAME, first);
         rv.put(CURRENT_USER_LAST_NAME, last);
         rv.put(CURRENT_USER_DISPLAY_NAME, user.getDisplayName());
         rv.put(CURRENT_USER_DISPLAY_ID, user.getDisplayId());
         rv.put("currentUserDispalyId", user.getDisplayId());
         
      } catch (Exception e) {
         log.warn("Failed to get current user replacements: " + userRef, e);
      }
   }
   /*NoN user fields */
   rv.put(LOCAL_SAKAI_NAME, serverConfigurationService.getString("ui.service", "Sakai"));
   rv.put(LOCAL_SAKAI_SUPPORT_MAIL,serverConfigurationService.getString("mail.support", "[email protected]"+ serverConfigurationService.getServerName()));
   rv.put(LOCAL_SAKAI_URL,serverConfigurationService.getServerUrl());

   
   return rv;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:36,代码来源:EmailTemplateServiceImpl.java

示例11: getActor

import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
public LRS_Actor getActor(String userId) {
    LRS_Actor actor = null;
    User user = null;
    try {
        user = this.userDirectoryService.getUser(userId);
    } catch (UserNotDefinedException e) {
        user = null;
    }
    if (user != null) {
        String actorEmail;
        if (StringUtils.isNotEmpty(user.getEmail())) {
            actorEmail = user.getEmail();
        } else {
            // no email set - make up something like one
            String server = serverConfigurationService.getServerName();
            if ("localhost".equals(server)) {
                server = "tincanapi.dev.sakaiproject.org";
            } else {
                server = serverConfigurationService.getServerId()+"."+server;
            }
            actorEmail = user.getId()+"@"+server;
            log.debug("LRS Actor: No email set for user ({}), using generated one: {}", user.getId(), actorEmail);
        }
        actor = new LRS_Actor(actorEmail);
        if (StringUtils.isNotEmpty(user.getDisplayName())) {
            actor.setName(user.getDisplayName());
        }
        // set actor account object
        actor.setAccount(user.getEid(), serverConfigurationService.getServerUrl());
        // TODO implement OpenID support
    }
    return actor;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:34,代码来源:BaseLearningResourceStoreService.java

示例12: getTo

import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
/**
 * Generate the To header based on the event data
 * @param event
 * @return
 */
private String getTo(Event event) {
    String to = null;
    try {
        User user = this.userDirectoryService.getUser(event.getContext());
        to = "To: " + user.getEmail();
    } catch (UserNotDefinedException e) {
        throw new IllegalStateException(e);
    }
    return to;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:16,代码来源:ExternalEmailNotification.java

示例13: sendEmailToUsers

import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
/**
	 * method to send email to Users.
	 * @param toAddress
	 * @param rt
	 * @param fromEmail
	 * @param fromName
	 */
	private void sendEmailToUsers(List<User> toAddress, RenderedTemplate rt, String fromEmail, String fromName){
		StringBuilder message = new StringBuilder();
		message.append(MIME_ADVISORY);
		if (rt.getRenderedMessage() != null) {
			message.append(BOUNDARY_LINE);
			message.append("Content-Type: text/plain; charset=iso-8859-1\n");
			message.append(rt.getRenderedMessage());
		}
		if (rt.getRenderedHtmlMessage() != null) {
			//append the HMTL part
			message.append(BOUNDARY_LINE);
			message.append("Content-Type: text/html; charset=iso-8859-1\n");
			message.append(rt.getRenderedHtmlMessage());
		}

		message.append(TERMINATION_LINE);

		// we need to manually construct the headers
		List<String> headers = new ArrayList<>();
		//the template may specify a from address
		if (StringUtils.isNotBlank(rt.getFrom())) {
			headers.add("From: \"" + rt.getFrom() );
		} else {
			headers.add("From: \"" + fromName + "\" <" + fromEmail + ">" );
		}
		// Add a To: header of either the recipient (if only 1), or the sender (if multiple)
		String toName = fromName;
		String toEmail = fromEmail;

		if (toAddress.size() == 1) {
			User u = toAddress.get(0);
			toName = u.getDisplayName();
			toEmail = u.getEmail();
		}

		headers.add("To: \"" + toName + "\" <" + toEmail + ">" );

		//SAK-21742 we need the rendered subject
		headers.add("Subject: " + rt.getRenderedSubject());
		headers.add("Content-Type: multipart/alternative; boundary=\"" + MULTIPART_BOUNDARY + "\"");
		headers.add("Mime-Version: 1.0");
		headers.add("Precedence: bulk");

		String body = message.toString();
		log.debug("message body " + body);
		emailService.sendToUsers(toAddress, headers, body);
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:55,代码来源:EmailTemplateServiceImpl.java

示例14: sendToUsers

import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public void sendToUsers(Collection<User> users, Collection<String> headers, String message)
{
	if (headers == null)
	{
		log.warn("sendToUsers: null headers");
		return;
	}

	if (m_testMode)
	{
		log.info("sendToUsers: users: " + usersToStr(users) + " headers: " + listToStr(headers) + " message:\n" + message);
		return;
	}

	if (m_smtp == null)
	{
		log.warn("sendToUsers: smtp not set");
		return;
	}

	if (users == null)
	{
		log.warn("sendToUsers: null users");
		return;
	}

	if (message == null)
	{
		log.warn("sendToUsers: null message");
		return;
	}

	// form the list of to: addresses from the users users collection
	ArrayList<InternetAddress> addresses = new ArrayList<InternetAddress>();
	for (User user : users)
	{
		String email = user.getEmail();
		if ((email != null) && (email.length() > 0))
		{
			try
			{
				addresses.add(new InternetAddress(email));
			}
			catch (AddressException e)
			{
				if (log.isDebugEnabled()) log.debug("sendToUsers: " + e);
			}
		}
	}

	// if we have none
	if (addresses.isEmpty()) return;

	// get separate sets
	List<Address[]> messageSets = getMessageSets(addresses);
	
	// get a session for our smtp setup, include host, port, reverse-path, and set partial delivery
	Properties props = createMailSessionProperties();

	Session session = Session.getInstance(props);

	// form our Message
	MimeMessage msg = new MyMessage(session, headers, message);

	// fix From and ReplyTo if necessary
	checkFrom(msg);

	// transport the message
	transportMessage(session, messageSets, headers, msg);
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:74,代码来源:BasicEmailService.java

示例15: getUserEmailsToBeNotifiedByLevel

import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
public List<String> getUserEmailsToBeNotifiedByLevel(List userlist) {
	List<String> emaillist = new ArrayList<String>();
	
	
	List<User> userMailList  = UserDirectoryService.getUsers(userlist);
	for (int i = 0; i < userMailList.size(); i++) {
		User user = userMailList.get(i); 


		String useremail = user.getEmail();
		if (useremail != null && !"".equalsIgnoreCase(useremail)) {
			if (log.isDebugEnabled()) {
				log.debug("Username = " + user.getDisplayId()
						+ " , useremail : " + useremail);
			}
			emaillist.add(useremail);
		}


	}
	
	return emaillist;
	
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:25,代码来源:DiscussionForumTool.java


注:本文中的org.sakaiproject.user.api.User.getEmail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。