本文整理匯總了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");
}