OSDN Git Service

新規登録画面追加
authorsenju <senju@users.sourceforge.jp>
Thu, 30 Jul 2009 18:40:28 +0000 (03:40 +0900)
committersenju <senju@users.sourceforge.jp>
Thu, 30 Jul 2009 18:40:28 +0000 (03:40 +0900)
.settings/org.eclipse.jdt.ui.prefs [new file with mode: 0644]
src/jp/sourceforge/rabbitBTS/controllers/RegisterController.java
src/jp/sourceforge/rabbitBTS/exceptions/NotRegisteredException.java
src/jp/sourceforge/rabbitBTS/exceptions/RabbitBTSException.java [new file with mode: 0644]
src/jp/sourceforge/rabbitBTS/models/UserProfile.java
src/jp/sourceforge/rabbitBTS/services/AccountServices.java
war/WEB-INF/appengine-generated/datastore-indexes-auto.xml
war/WEB-INF/views/index.jsp
war/WEB-INF/views/register/index.jsp [new file with mode: 0644]

diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644 (file)
index 0000000..6e6261d
--- /dev/null
@@ -0,0 +1,56 @@
+#Wed Jul 29 20:41:23 JST 2009
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+org.eclipse.jdt.ui.javadoc=false
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*\n   Copyright 2009 senju@users.sourceforge.jp\n\n   Licensed under the Apache License, Version 2.0 (the "License");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http\://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an "AS IS" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\n</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n *\n * ${tags}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter function" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter function" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="filecomment_context" deleted\="false" description\="Comment for created JavaScript files" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.filecomment" name\="filecomment">/**\n * \n */</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @author ${user}\n *\n * ${tags}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for vars" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding function" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding functions" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Jsdoc)\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate functions" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created function stubs" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated function stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=true
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_to_enhanced_for_loop=true
+sp_cleanup.correct_indentation=false
+sp_cleanup.format_source_code=true
+sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.make_local_variable_final=true
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=true
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=true
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_trailing_whitespaces=false
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=false
+sp_cleanup.remove_unused_imports=false
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_blocks=true
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=true
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=false
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
index 18c4f1f..f9c4b1c 100644 (file)
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-*/
-
+ */
 
 package jp.sourceforge.rabbitBTS.controllers;
 
+import java.util.logging.Level;
+
 import javax.servlet.http.HttpServletRequest;
 
 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.services.AccountServices;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.validation.BindingResult;
+import org.springframework.validation.Validator;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 
-
 @Controller
 public class RegisterController implements IController {
+       private static final String REDIRECT_HOME_HTML = "redirect:/home.html";
+
        @Autowired
        private AccountServices accountServices;
 
+       @Autowired
+       private Validator validator;
+
+       /**
+        * 新規登録画面を表示する。
+        * <p>
+        * ユーザーがgoogleにログインしていない場合、googleのログイン画面にリダイレクトする。
+        * ユーザーがアカウントを持っている場合、ユーザーホームにリダイレクトする。
+        * ユーザーがgoogleにログイン済みでかつアカウントを持っていない時だけ、画面を表示する。
+        * 
+        * @param req
+        * @param map
+        * @return
+        */
        @RequestMapping(method = RequestMethod.GET)
-       public String index(HttpServletRequest req) {
+       public String index(HttpServletRequest req, ModelMap map) {
+               String ret = null;
                try {
-                       UserProfile up = accountServices.fetchUserProfile();
+                       final UserProfile up = this.accountServices.fetchUserProfile();
                        if (up == null) {
                                // googleにログインしてない場合
-                               return Sht.loginUrl(req);
+                               Sht.log(this).finer("ログインが必要");
+                               ret = "redirect:" + Sht.loginUrl(req);
                        } else {
                                // すでに登録済みの場合ホームへリダイレクト
-                               return "redirect:/home.html";
+                               Sht.log(this).finer("既に登録済み");
+                               ret = REDIRECT_HOME_HTML;
                        }
-               } catch (NotRegisteredException e) {
+               } catch (final NotRegisteredException e) {
                        // 正常系
+                       map.addAttribute(new UserProfile());
+                       ret = null;
+               }
+               return ret;
+       }
+
+       /**
+        * 新規登録を行う。
+        * 
+        * <p>
+        * 正常系
+        * <ol>
+        * <li>バリデート
+        * <li>UserProfileを登録
+        * <li>ユーザーホームにリダイレクト
+        * <ol>
+        * <p>
+        * 異常系
+        * <ol>
+        * <li>バリデートに失敗した場合、エラーメッセージ
+        * <li>UserProfile登録に失敗した場合(二重登録等)、ロールバック、エラーメッセージ
+        * </ol>
+        * 
+        * @param user
+        * @param result
+        * @return
+        */
+       @RequestMapping(method = RequestMethod.POST)
+       public String index(UserProfile user, BindingResult result, ModelMap map) {
+               this.validator.validate(user, result);
+               if (result.hasErrors()) {
+                       Sht.log(this).finer("ユーザ登録画面にてバリデートに失敗");
+                       return null;
+               }
+
+               try {
+                       this.accountServices.registUserProfile(user);
+               } catch (final RabbitBTSException e) {
+                       Sht.log(this).log(Level.WARNING, "ユーザー登録で例外発生", e);
+                       map.addAttribute("errorMessage", "登録に失敗しました。再度やりなおしてください。");
                        return null;
                }
+               return REDIRECT_HOME_HTML;
        }
 }
index e547eb9..4e253cd 100644 (file)
@@ -12,8 +12,7 @@
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-*/
-
+ */
 
 package jp.sourceforge.rabbitBTS.exceptions;
 
@@ -24,7 +23,7 @@ package jp.sourceforge.rabbitBTS.exceptions;
  * 
  */
 @SuppressWarnings("serial")
-public class NotRegisteredException extends Exception {
+public class NotRegisteredException extends RabbitBTSException {
 
        // TODO: リファクタリング(国際化どうやんだ?)
        private static final String msg = "ユーザーが新規登録を行っていません。";
diff --git a/src/jp/sourceforge/rabbitBTS/exceptions/RabbitBTSException.java b/src/jp/sourceforge/rabbitBTS/exceptions/RabbitBTSException.java
new file mode 100644 (file)
index 0000000..55605cc
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+   Copyright 2009 senju@users.sourceforge.jp
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ */
+
+package jp.sourceforge.rabbitBTS.exceptions;
+
+/**
+ * Rabbit BTS共通の例外
+ */
+@SuppressWarnings("serial")
+public class RabbitBTSException extends Exception {
+
+       /**
+        * 
+        */
+       public RabbitBTSException() {
+               // TODO Auto-generated constructor stub
+       }
+
+       /**
+        * @param message
+        */
+       public RabbitBTSException(String message) {
+               super(message);
+               // TODO Auto-generated constructor stub
+       }
+
+       /**
+        * @param cause
+        */
+       public RabbitBTSException(Throwable cause) {
+               super(cause);
+               // TODO Auto-generated constructor stub
+       }
+
+       /**
+        * @param message
+        * @param cause
+        */
+       public RabbitBTSException(String message, Throwable cause) {
+               super(message, cause);
+               // TODO Auto-generated constructor stub
+       }
+
+}
index 6eaca6e..991c5bd 100644 (file)
@@ -25,6 +25,9 @@ import javax.jdo.annotations.PersistenceCapable;
 import javax.jdo.annotations.Persistent;
 import javax.jdo.annotations.PrimaryKey;
 
+import org.springmodules.validation.bean.conf.loader.annotation.handler.Length;
+import org.springmodules.validation.bean.conf.loader.annotation.handler.NotBlank;
+
 import com.google.appengine.api.users.User;
 
 @PersistenceCapable(identityType = IdentityType.APPLICATION)
@@ -37,6 +40,17 @@ public class UserProfile {
        @Persistent
        private User gu;
 
+       /**
+        * 自己紹介
+        */
+       @Persistent
+       @NotBlank
+       @Length(max=255) // TODO:サロゲートありで満杯までいれると500byte越えるかもね。
+       private String bio;
+       
+       /**
+        * 最後にシステムにアクセスした日時
+        */
        @Persistent
        private Date lastAccess;
 
@@ -59,4 +73,18 @@ public class UserProfile {
        public void setLastAccess(Date lastAccess) {
                this.lastAccess = lastAccess;
        }
+
+       /**
+        * @return the bio
+        */
+       public String getBio() {
+               return bio;
+       }
+
+       /**
+        * @param bio the bio to set
+        */
+       public void setBio(String bio) {
+               this.bio = bio;
+       }
 }
index ecf0be5..292f75b 100644 (file)
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-*/
-
+ */
 
 package jp.sourceforge.rabbitBTS.services;
 
+import java.util.Date;
 import java.util.List;
 
+import javax.jdo.PersistenceManager;
 import javax.jdo.Query;
+import javax.jdo.Transaction;
 
 import jp.sourceforge.rabbitBTS.PMF;
 import jp.sourceforge.rabbitBTS.Sht;
 import jp.sourceforge.rabbitBTS.exceptions.NotRegisteredException;
+import jp.sourceforge.rabbitBTS.exceptions.RabbitBTSException;
 import jp.sourceforge.rabbitBTS.models.UserProfile;
 
 import org.springframework.stereotype.Service;
 
-
 import com.google.appengine.api.users.User;
 
 /**
  * アカウント/ユーザープロファイルまわりのサービス
+ * 
  * @author senju
  */
 @Service()
@@ -42,23 +45,67 @@ public class AccountServices {
         * 現在ログイン中のgoogleアカウントのユーザープロファイルを取得する。
         * 
         * @return 取得したユーザープロファイル。ログインしていない場合はnull
-        * @throws NotRegisteredException 未登録ユーザーの場合
+        * @throws NotRegisteredException
+        *             未登録ユーザーの場合
         */
        @SuppressWarnings("unchecked")
        public UserProfile fetchUserProfile() throws NotRegisteredException {
-               User gu = Sht.user();
-               if(gu == null){
+               final User gu = Sht.user();
+               if (gu == null) {
                        return null;
                }
-               Query q = PMF.get().getPersistenceManager().newQuery(UserProfile.class);
+               final Query q = PMF.get().getPersistenceManager().newQuery(
+                               UserProfile.class);
                q.setFilter("gu == u");
                q.declareImports("import com.google.appengine.api.users.User;");
                q.declareParameters("User u");
-               List<UserProfile> up = (List<UserProfile>) q.execute(gu);
-               if(up.size() == 0){
+               final List<UserProfile> up = (List<UserProfile>) q.execute(gu);
+               if (up.size() == 0) {
                        throw new NotRegisteredException();
                }
 
                return up.get(0);
        }
+
+       /**
+        * 指定されたユーザープロファイルを登録する。
+        * 
+        * @param userProfile
+        *            登録するユーザープロファイル
+        * @throws RabbitBTSException
+        *             既に登録済みの場合
+        */
+       public void registUserProfile(UserProfile userProfile)
+                       throws RabbitBTSException {
+
+               final PersistenceManager pm = PMF.get().getPersistenceManager();
+               final Transaction tx = pm.currentTransaction();
+               try {
+                       tx.begin();
+                       try {
+                               // 登録済みチェック
+                               final UserProfile up = this.fetchUserProfile();
+                               if (up != null) {
+                                       throw new RabbitBTSException("既に登録されています。");
+                               } else {
+                                       throw new RabbitBTSException("googleにログインしてください。");
+                               }
+                       } catch (final NotRegisteredException e) {
+                               // OK
+                       }
+
+                       // 登録処理
+                       userProfile.setGu(Sht.user());
+                       userProfile.setLastAccess(new Date());
+                       pm.makePersistent(userProfile);
+
+                       // TODO: メッセージ追加
+
+                       tx.commit();
+               } finally {
+                       if (tx.isActive()) {
+                               tx.rollback();
+                       }
+               }
+       }
 }
index 64b9832..521e6fd 100644 (file)
@@ -1,4 +1,4 @@
-<!-- Indices written at Wed, 29 Jul 2009 08:48:45 UTC -->
+<!-- Indices written at Thu, 30 Jul 2009 17:32:47 UTC -->
 
 <datastore-indexes/>
 
index 9fc83c2..fb06113 100644 (file)
@@ -13,6 +13,8 @@
 <a href="/home.html">ユーザー名</a>
 </div>
 <h1>Rabbit BTSへようこそ</h1>
-<a href="/bbs">BBS</a>
+<ul>
+<li><a href="/bbs">BBS</a></li>
+<li><a href="http://localhost:8080/_ah/admin/datastore">data viewer</a></li></ul>
 </body>
 </html>
\ No newline at end of file
diff --git a/war/WEB-INF/views/register/index.jsp b/war/WEB-INF/views/register/index.jsp
new file mode 100644 (file)
index 0000000..ab47339
--- /dev/null
@@ -0,0 +1,21 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<%@ page language="java" contentType="text/html; charset=UTF-8"%>
+<%@include file="/WEB-INF/views/header.jsp"%>
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<title>Rabbit BTS - 新規登録画面</title>
+</head>
+<body>
+<h1>Rabbit BTSへようこそ</h1>
+<p>新しくRabbit BTSアカウントを作成します。以下のフォームを入力し、作成ボタンをクリックしてください。</p>
+<c:if test="${errorMessage != null}">${errorMessage}</c:if>
+<form:form modelAttribute="userProfile" method="post">
+<ul>
+<li>自己紹介 <form:errors path="bio"></form:errors> <form:textarea path="bio" /></li>
+<li><input type="submit" value="作成" /></li>
+</ul>
+</form:form>
+</body>
+</html>
\ No newline at end of file