本文整理汇总了Java中play.mvc.Controller.session方法的典型用法代码示例。如果您正苦于以下问题:Java Controller.session方法的具体用法?Java Controller.session怎么用?Java Controller.session使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类play.mvc.Controller
的用法示例。
在下文中一共展示了Controller.session方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCurrentStatementLanguage
import play.mvc.Controller; //导入方法依赖的package包/类
public String getCurrentStatementLanguage() {
String lang = Controller.session("currentStatementLanguage");
if (lang == null) {
return "en-US";
}
return lang;
}
示例2: set
import play.mvc.Controller; //导入方法依赖的package包/类
/**
* Register the given user as the current user. (As part of logging in or switching to another user.)
* Admin roles are not automatically active. Use {@link #setAdmin(java.util.Set)} for that.
* @param user partially filled in user object
*/
public static void set (UserHeader user, Set<UserRole> roleSet) {
Controller.session("id", Integer.toString(user.getId()));
Controller.session("email", user.getEmail());
Controller.session("fullName", user.getFullName());
clearAdmin(roleSet);
Controller.session("status", user.getStatus().name());
Controller.session("pa", Boolean.toString(isAdmin(roleSet))); // can this user promote to admin
}
示例3: clearAdmin
import play.mvc.Controller; //导入方法依赖的package包/类
/**
* Reset the roles to the restricted set.
*/
public static void clearAdmin (Set<UserRole> roleSet) {
EnumSet<UserRole> es = EnumSet.copyOf(RESTRICTED_ROLES);
es.retainAll(roleSet);
if (roleSet.contains(UserRole.SUPER_USER)) {
es.add(UserRole.CAR_USER); // to avoid problems with super users that are not members
}
Controller.session("roles", UserRole.toString(es));
}
示例4: getDisplayName
import play.mvc.Controller; //导入方法依赖的package包/类
/**
* Retrieve the display name of the current user. Format: FirstName Name
*/
public static String getDisplayName() {
String fullName = Controller.session("fullName");
if (fullName == null) {
return null;
} else {
int pos = fullName.indexOf(',');
return fullName.substring(pos + 2) + fullName.substring (0, pos);
}
}
示例5: hasRole
import play.mvc.Controller; //导入方法依赖的package包/类
/**
* Whether the current user is logged in and has the given role.
*/
public static boolean hasRole (Role role) {
String roleString = Controller.session("role");
return roleString != null && Role.valueOf(roleString) == role;
}
示例6: isLoggedOut
import play.mvc.Controller; //导入方法依赖的package包/类
/**
* Whether the current user is logged in
*/
public static boolean isLoggedOut () {
return Controller.session("id") == null;
}
示例7: setCurrentStatementLanguage
import play.mvc.Controller; //导入方法依赖的package包/类
public void setCurrentStatementLanguage(String languageCode) {
Controller.session("currentStatementLanguage", languageCode);
}
示例8: setAdmin
import play.mvc.Controller; //导入方法依赖的package包/类
/**
* Increase the roles to the full set.
*/
public static void setAdmin (Set<UserRole> roleSet) {
Controller.session("roles", UserRole.toString(roleSet));
}
示例9: getId
import play.mvc.Controller; //导入方法依赖的package包/类
/**
* Retrieve the id of the current user, or 0 if there is no current user.
*/
public static int getId () {
String idString = Controller.session("id");
return idString == null ? 0 : Integer.parseInt(idString);
}
示例10: is
import play.mvc.Controller; //导入方法依赖的package包/类
/**
* Check whether the given user correspond to the current user
*/
public static boolean is(int userId) {
String idString = Controller.session("id");
return idString != null && Integer.parseInt(idString) == userId;
}
示例11: isNot
import play.mvc.Controller; //导入方法依赖的package包/类
/**
* Short for <code>! is(userId)</code>
*/
public static boolean isNot(int userId) {
String idString = Controller.session("id");
return idString == null || Integer.parseInt(idString) != userId;
}
示例12: getFullName
import play.mvc.Controller; //导入方法依赖的package包/类
/**
* Retrieve the full name of the current user. Format: Name, FirstName
*/
public static String getFullName () {
return Controller.session("fullName");
}