本文整理汇总了Java中org.sakaiproject.user.api.User类的典型用法代码示例。如果您正苦于以下问题:Java User类的具体用法?Java User怎么用?Java User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
User类属于org.sakaiproject.user.api包,在下文中一共展示了User类的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;
}
示例2: isUserStudent
import org.sakaiproject.user.api.User; //导入依赖的package包/类
/**
* Check if the specified user has the student role on the specified site.
* @param siteId Site ID
* @param userId User ID
* @return true if user has student role on the site.
*/
public boolean isUserStudent(String siteId, String userId){
boolean isStudent=false;
try{
Set<String> studentIds = siteService.getSite(siteId).getUsersIsAllowed("section.role.student");
List<User> activeUsers = userDirectoryService.getUsers(studentIds);
for (int i = 0; i < activeUsers.size(); i++) {
User user = activeUsers.get(i);
if(userId.equals(user.getId())){
return true;
}
}
}catch(Exception e){
log.info("(isStudentUser)"+e);
}
return isStudent;
}
示例3: getProfileImage
import org.sakaiproject.user.api.User; //导入依赖的package包/类
@EntityCustomAction(action = "details", viewKey = EntityView.VIEW_LIST)
public Object getProfileImage(OutputStream out, EntityView view, Map<String,Object> params) {
JSONObject result = new JSONObject();
result.put("status", "ERROR");
User currentUser = UserDirectoryService.getCurrentUser();
String currentUserId = currentUser.getId();
if (currentUserId == null) {
log.warn("Access denied");
return result.toJSONString();
}
String imageUrl = imageLogic.getProfileImageEntityUrl(currentUserId, ProfileConstants.PROFILE_IMAGE_MAIN);
result.put("url", imageUrl);
result.put("isDefault", imageLogic.profileImageIsDefault(currentUserId));
result.put("csrf_token", sessionManager.getCurrentSession().getAttribute("sakai.csrf.token"));
result.put("status", "SUCCESS");
return result.toJSONString();
}
示例4: getImpersonatorDisplayId
import org.sakaiproject.user.api.User; //导入依赖的package包/类
/**
* Checks if current user is being impersonated (via become user/sutool) and returns displayId of
* the impersonator. Adapted from SkinnableLogin's isImpersonating()
* @return displayId of impersonator, or empty string if not being impersonated
*/
private String getImpersonatorDisplayId()
{
Session currentSession = SessionManager.getCurrentSession();
UsageSession originalSession = (UsageSession) currentSession.getAttribute(UsageSessionService.USAGE_SESSION_KEY);
if (originalSession != null)
{
String originalUserId = originalSession.getUserId();
if (!StringUtils.equals(currentSession.getUserId(), originalUserId))
{
try
{
User originalUser = UserDirectoryService.getUser(originalUserId);
return originalUser.getDisplayId();
}
catch (UserNotDefinedException e)
{
log.debug("Unable to retrieve user for id: {}", originalUserId);
}
}
}
return "";
}
示例5: getUserLastName
import org.sakaiproject.user.api.User; //导入依赖的package包/类
/**
* Get user last Name. If turnitin.generate.last.name is set to true last
* name is anonamised
*
* @param user
* @return
*/
private String getUserLastName(User user) {
String uln = user.getLastName().trim();
if (uln == null || uln.equals("")) {
boolean genLN = serverConfigurationService.getBoolean("turnitin.generate.last.name", false);
if (genLN) {
String eid = user.getEid();
if (eid != null && eid.length() > 0) {
uln = eid.substring(0, 1);
} else {
uln = "X";
}
}
}
return uln;
}
示例6: getUserDisplayName
import org.sakaiproject.user.api.User; //导入依赖的package包/类
/**
* Gets the display name for a given user
* <p/>
* Differs from original above as that one uses the session to get the displayname 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 display name for any user.
*
* @param sessionid the id of a valid session
* @param userid the login username (ie jsmith26) of the user you want the display name for
* @return the display name for the user
* @throws RuntimeException
*/
@WebMethod
@Path("/getUserDisplayName")
@Produces("text/plain")
@GET
public String getUserDisplayName(
@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.getDisplayName();
} catch (Exception e) {
log.error("WS getUserDisplayName() failed for user: " + userid + " : " + e.getClass().getName() + " : " + e.getMessage());
return "";
}
}
示例7: postNotification
import org.sakaiproject.user.api.User; //导入依赖的package包/类
/**
* Handles a request to create a new notification. Expects /notify/post/{userEId}
*
* @param view
* @param params
* @return
*/
@EntityCustomAction(action = "post", viewKey = EntityView.VIEW_NEW)
public void postNotification(EntityView view, Map<String, Object> params) {
if (log.isDebugEnabled()) {
log.debug("postNotification params: " + params);
}
if (!isEnabled()) {
throw new IllegalStateException("Service is disabled. Check your configuration ("+NOTIFY_POST_ENABLED+" must be true)!");
} else {
isAuthorized(); // does check and throws exception if fails to pass
String userEId = getUserEId(view);
User user = getUserByEId(userEId);
String notification = getNotification(params);
emailNotification.addMessage(notification);
Event event = eventTrackingService.newEvent("rest.notify.post", null, user.getId(), false, NotificationService.NOTI_OPTIONAL);
eventTrackingService.post(event);
}
}
示例8: getHeaders
import org.sakaiproject.user.api.User; //导入依赖的package包/类
@Override
protected List<String> getHeaders(Event event)
{
List<String> rv = super.getHeaders(event);
// the Subject
rv.add("Subject: " + getSubject(event));
// from
rv.add(getFrom(event));
// to
List toList = getRecipients(event);
Iterator itr = toList.iterator();
StringBuilder recips = new StringBuilder();
while (itr.hasNext())
{
User usr = (User) itr.next();
recips.append(usr.getEmail() + ", ");
}
rv.add("To: " + recips.toString());
return rv;
}
示例9: getDisplayId
import org.sakaiproject.user.api.User; //导入依赖的package包/类
public String getDisplayId(User user) {
String displayId = null;
if (myProvider instanceof DisplayAdvisorUDP) {
displayId = ((DisplayAdvisorUDP)myProvider).getDisplayId(user);
if (displayId != null) {
return displayId;
}
}
if (nextProvider instanceof DisplayAdvisorUDP) {
displayId = ((DisplayAdvisorUDP)nextProvider).getDisplayId(user);
if (displayId != null) {
return displayId;
}
}
return null;
}
示例10: getAllPossbileCoordinatorsOnFastTrack
import org.sakaiproject.user.api.User; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
public List<SignupUser> getAllPossbileCoordinatorsOnFastTrack(SignupMeeting meeting) {
List<SignupUser> coordinators = new ArrayList<SignupUser>();
List<SignupSite> signupSites = meeting.getSignupSites();
Set<String> userIdsHasPermissionToCreate = new HashSet<String>();
if (signupSites != null) {
for (SignupSite site: signupSites) {
//Only thing we miss here is that the view permission is not checked. the Chance is very small.
userIdsHasPermissionToCreate.addAll(getUserIdsHasPermissionToCreate(site));
}
}
List<User> sakaiUsers = userDirectoryService.getUsers(userIdsHasPermissionToCreate);
for (User user : sakaiUsers) {
SignupUser signupUser = new SignupUser(user.getEid(), user.getId(), user.getFirstName(), user.getLastName(),
null, "", true);
coordinators.add(signupUser);
}
return coordinators;
}
示例11: getUserFirstName
import org.sakaiproject.user.api.User; //导入依赖的package包/类
/**
* Gets a first name for a user or generates an initial from the eid
*
* @param user
* a sakai user
* @return the first name or at least an initial if possible, "X" if no fn
* can be made
*/
private String getUserFirstName(User user) {
String ufn = user.getFirstName().trim();
if (ufn == null || ufn.equals("")) {
boolean genFN = (boolean) serverConfigurationService.getBoolean("turnitin.generate.first.name", true);
if (genFN) {
String eid = user.getEid();
if (eid != null && eid.length() > 0) {
ufn = eid.substring(0, 1);
} else {
ufn = "X";
}
}
}
return ufn;
}
示例12: getActiveBannersJSON
import org.sakaiproject.user.api.User; //导入依赖的package包/类
private String getActiveBannersJSON() {
JSONArray banners = new JSONArray();
String serverId = ServerConfigurationService.getString("serverId", "localhost");
User currentUser = UserDirectoryService.getCurrentUser();
if (currentUser != null && currentUser.getId() != null && !"".equals(currentUser.getId())) {
for (Banner banner : getBanners().getRelevantBanners(serverId, currentUser.getId())) {
try {
JSONObject bannerData = new JSONObject();
bannerData.put("id", banner.getUuid());
bannerData.put("message", banner.getMessage());
bannerData.put("dismissible", banner.isDismissible());
bannerData.put("dismissed", banner.isDismissed());
bannerData.put("type", banner.getType());
banners.add(bannerData);
} catch (Exception e) {
log.warn("Error processing banner: " + banner, e);
}
}
}
return banners.toJSONString();
}
示例13: getUserMap
import org.sakaiproject.user.api.User; //导入依赖的package包/类
private Map<String, User> getUserMap(Set<Member> members) {
Map<String, User> userMap = new HashMap<String, User>();
Set<String> userIds = new HashSet<String>();
// Build a map of userId to role
for (Member member : members) {
if (member.isActive()) {
userIds.add(member.getUserId());
}
}
// Get the user objects
for (User user : userDirectoryService.getUsers(userIds)) {
userMap.put(user.getId(), user);
}
return userMap;
}
示例14: getUserDisplayName
import org.sakaiproject.user.api.User; //导入依赖的package包/类
public String getUserDisplayName(String userId) {
try {
User user = userDirectoryService.getUser(userId);
return user.getDisplayName();
} catch (UserNotDefinedException ex) {
log.error("Could not get user from userId: " + userId, ex);
}
if (userId.startsWith(ANON_USER_PREFIX)) {
return "Anonymous User";
}
return "----------";
}
示例15: getCurrentUserDisplayName
import org.sakaiproject.user.api.User; //导入依赖的package包/类
public String getCurrentUserDisplayName(){
User user = userDirectoryService.getCurrentUser();
if(user != null){
return user.getDisplayName();
}
return "";
}