import jp.sourceforge.rabbitBTS.Sht;
import jp.sourceforge.rabbitBTS.exceptions.NotRegisteredException;
import jp.sourceforge.rabbitBTS.exceptions.RabbitBTSException;
-import jp.sourceforge.rabbitBTS.models.UserProfile;
+import jp.sourceforge.rabbitBTS.models.Account;
import jp.sourceforge.rabbitBTS.services.AccountServices;
import org.springframework.beans.factory.annotation.Autowired;
public String index(HttpServletRequest req, ModelMap map) {
String ret = null;
try {
- final UserProfile up = this.accountServices.fetchUserProfile();
+ final Account up = this.accountServices.fetchAccount();
if (up == null) {
// googleにログインしてない場合
Sht.log(this).finer("ログインが必要");
}
} catch (final NotRegisteredException e) {
// 正常系
- map.addAttribute(new UserProfile());
+ map.addAttribute(new Account());
ret = null;
}
return ret;
* @return
*/
@RequestMapping(method = RequestMethod.POST)
- public String index(UserProfile user, BindingResult result, ModelMap map) {
+ public String index(Account user, BindingResult result, ModelMap map) {
this.validator.validate(user, result);
if (result.hasErrors()) {
Sht.log(this).finer("ユーザ登録画面にてバリデートに失敗");
}
try {
- this.accountServices.registUserProfile(user);
+ this.accountServices.registAccount(user);
} catch (final RabbitBTSException e) {
Sht.log(this).log(Level.WARNING, "ユーザー登録で例外発生", e);
map.addAttribute("errorMessage", "登録に失敗しました。再度やりなおしてください。");
import jp.sourceforge.rabbitBTS.Sht;
import jp.sourceforge.rabbitBTS.exceptions.NotRegisteredException;
import jp.sourceforge.rabbitBTS.exceptions.RabbitBTSException;
-import jp.sourceforge.rabbitBTS.models.UserProfile;
+import jp.sourceforge.rabbitBTS.models.Account;
import org.springframework.stereotype.Service;
import com.google.appengine.api.users.User;
/**
- * ã\82¢ã\82«ã\82¦ã\83³ã\83\88/ã\83¦ã\83¼ã\82¶ã\83¼ã\83\97ã\83ã\83\95ã\82¡ã\82¤ã\83«まわりのサービス
+ * ã\82¢ã\82«ã\82¦ã\83³ã\83\88/ã\82¢ã\82«ã\82¦ã\83³ã\83\88まわりのサービス
*
* @author senju
*/
public class AccountServices {
/**
- * ç\8f¾å\9c¨ã\83ã\82°ã\82¤ã\83³ä¸ã\81®googleã\82¢ã\82«ã\82¦ã\83³ã\83\88ã\81®ã\83¦ã\83¼ã\82¶ã\83¼ã\83\97ã\83ã\83\95ã\82¡ã\82¤ã\83«を取得する。
+ * ç\8f¾å\9c¨ã\83ã\82°ã\82¤ã\83³ä¸ã\81®googleã\82¢ã\82«ã\82¦ã\83³ã\83\88ã\81®ã\82¢ã\82«ã\82¦ã\83³ã\83\88を取得する。
*
- * @return å\8f\96å¾\97ã\81\97ã\81\9fã\83¦ã\83¼ã\82¶ã\83¼ã\83\97ã\83ã\83\95ã\82¡ã\82¤ã\83«。ログインしていない場合はnull
+ * @return å\8f\96å¾\97ã\81\97ã\81\9fã\82¢ã\82«ã\82¦ã\83³ã\83\88。ログインしていない場合はnull
* @throws NotRegisteredException
* 未登録ユーザーの場合
*/
@SuppressWarnings("unchecked")
- public UserProfile fetchUserProfile() throws NotRegisteredException {
+ public Account fetchAccount() throws NotRegisteredException {
final User gu = Sht.user();
if (gu == null) {
return null;
}
final Query q = PMF.get().getPersistenceManager().newQuery(
- UserProfile.class);
+ Account.class);
q.setFilter("gu == u");
q.declareImports("import com.google.appengine.api.users.User;");
q.declareParameters("User u");
- final List<UserProfile> up = (List<UserProfile>) q.execute(gu);
+ final List<Account> up = (List<Account>) q.execute(gu);
if (up.size() == 0) {
throw new NotRegisteredException();
}
}
/**
- * æ\8c\87å®\9aã\81\95ã\82\8cã\81\9fã\83¦ã\83¼ã\82¶ã\83¼ã\83\97ã\83ã\83\95ã\82¡ã\82¤ã\83«を登録する。
+ * æ\8c\87å®\9aã\81\95ã\82\8cã\81\9fã\82¢ã\82«ã\82¦ã\83³ã\83\88を登録する。
*
- * @param userProfile
- * ç\99»é\8c²ã\81\99ã\82\8bã\83¦ã\83¼ã\82¶ã\83¼ã\83\97ã\83ã\83\95ã\82¡ã\82¤ã\83«
+ * @param account
+ * ç\99»é\8c²ã\81\99ã\82\8bã\82¢ã\82«ã\82¦ã\83³ã\83\88
* @throws RabbitBTSException
* 既に登録済みの場合
*/
- public void registUserProfile(UserProfile userProfile)
+ public void registAccount(Account account)
throws RabbitBTSException {
final PersistenceManager pm = PMF.get().getPersistenceManager();
tx.begin();
try {
// 登録済みチェック
- final UserProfile up = this.fetchUserProfile();
+ final Account up = this.fetchAccount();
if (up != null) {
throw new RabbitBTSException("既に登録されています。");
} else {
}
// 登録処理
- userProfile.setGu(Sht.user());
- userProfile.setLastAccess(new Date());
- pm.makePersistent(userProfile);
+ account.setGu(Sht.user());
+ account.setLastAccess(new Date());
+ pm.makePersistent(account);
// TODO: メッセージ追加