From 2a792e936679d5ddee39d7021acc1f2c0363d740 Mon Sep 17 00:00:00 2001
From: yusuke.kokubo <yusuke.kokubo@gmail.com>
Date: Wed, 11 May 2011 16:55:29 +0900
Subject: [PATCH] =?UTF-8?q?=E3=83=AD=E3=82=B0=E3=82=A4=E3=83=B3=E5=BE=8C=E3=81=AB=E5=85=83=E3=81=84=E3=81=9F=E3=83=9A=E3=83=BC=E3=82=B8=E3=81=AB=E6=88=BB=E3=82=8C=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F=20refs=20#722?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

  -  ちょっと無理やり感が強い
---
 src/com/appspot/skillmaps/client/Skillmaps.java    |   25 +++++++++++++++----
 .../server/service/AccountServiceImpl.java         |    1 +
 src/com/appspot/skillmaps/shared/model/Login.java  |    9 +++++++
 war/WEB-INF/appengine-web.xml                      |    2 +-
 4 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/src/com/appspot/skillmaps/client/Skillmaps.java b/src/com/appspot/skillmaps/client/Skillmaps.java
index 98bb673..536d502 100644
--- a/src/com/appspot/skillmaps/client/Skillmaps.java
+++ b/src/com/appspot/skillmaps/client/Skillmaps.java
@@ -8,6 +8,9 @@ import com.appspot.skillmaps.client.ui.Header;
 import com.appspot.skillmaps.shared.model.Login;
 import com.google.gwt.core.client.EntryPoint;
 import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.logical.shared.ValueChangeEvent;
+import com.google.gwt.event.logical.shared.ValueChangeHandler;
+import com.google.gwt.user.client.History;
 import com.google.gwt.user.client.Window;
 import com.google.gwt.user.client.rpc.AsyncCallback;
 import com.google.gwt.user.client.ui.RootPanel;
@@ -28,12 +31,13 @@ public class Skillmaps implements EntryPoint {
         RootPanel.get("contents").add(contentsPanel);
 
         RootPanel.get("footer").add(new Footer());
-        injector.getAccountService().login(GWT.getHostPageBaseURL() + Window.Location.getQueryString(),
+        injector.getAccountService().login(GWT.getHostPageBaseURL() + 
+                                           Window.Location.getQueryString() + 
+                                           Window.Location.getHash(),
             new AsyncCallback<Login>() {
-
                 @Override
                 public void onSuccess(Login result) {
-                    Login login = injector.getLogin();
+                    final Login login = injector.getLogin();
                     login.setAdmin(result.isAdmin());
                     login.setEmailAddress(result.getEmailAddress());
                     login.setKey(result.getKey());
@@ -44,13 +48,24 @@ public class Skillmaps implements EntryPoint {
                     login.setProfile(result.getProfile());
                     login.setReceiveEmail(result.getReceiveEmail());
                     login.setVersion(result.getVersion());
+                    login.setRawLoginUrl(result.getRawLoginUrl());
 
                     //TODO headerもdisplay化？
                     RootPanel.get("header").clear();
                     RootPanel.get("header").add(new Header(login));
 
+                    History.addValueChangeHandler(new ValueChangeHandler<String>() {
+                        @Override
+                        public void onValueChange(ValueChangeEvent<String> event) {
+                            login.setLoginUrl(login.getRawLoginUrl()+
+                                GWT.getHostPageBaseURL() + 
+                                Window.Location.getQueryString() + 
+                                Window.Location.getHash());
+                            RootPanel.get("header").clear();
+                            RootPanel.get("header").add(new Header(login));
+                        }
+                    });
                     injector.getHistoryHandler().handleCurrentHistory();
-
                 }
 
                 @Override
@@ -58,7 +73,5 @@ public class Skillmaps implements EntryPoint {
                     Window.alert("初期処理に失敗しました。再表示してください。");
                 }
         });
-
     }
-
 }
diff --git a/src/com/appspot/skillmaps/server/service/AccountServiceImpl.java b/src/com/appspot/skillmaps/server/service/AccountServiceImpl.java
index 6bdd419..8a6d2d7 100644
--- a/src/com/appspot/skillmaps/server/service/AccountServiceImpl.java
+++ b/src/com/appspot/skillmaps/server/service/AccountServiceImpl.java
@@ -56,6 +56,7 @@ public class AccountServiceImpl implements AccountService {
         } else {
             login.setLoggedIn(false);
             login.setLoginUrl(userService.createLoginURL(requestUri));
+            login.setRawLoginUrl(userService.createLoginURL(""));
         }
 
         return login;
diff --git a/src/com/appspot/skillmaps/shared/model/Login.java b/src/com/appspot/skillmaps/shared/model/Login.java
index fa01eb1..af4ba8c 100644
--- a/src/com/appspot/skillmaps/shared/model/Login.java
+++ b/src/com/appspot/skillmaps/shared/model/Login.java
@@ -18,6 +18,7 @@ public class Login implements Serializable {
     private String receiveEmail;
     private boolean admin;
     private Profile profile;
+    private String rawLoginUrl;
 
     public Key getKey() {
         return key;
@@ -129,4 +130,12 @@ public class Login implements Serializable {
         return admin;
     }
 
+    public void setRawLoginUrl(String rawLoginUrl) {
+        this.rawLoginUrl = rawLoginUrl;
+    }
+
+    public String getRawLoginUrl() {
+        return rawLoginUrl;
+    }
+
 }
diff --git a/war/WEB-INF/appengine-web.xml b/war/WEB-INF/appengine-web.xml
index a337483..af5d171 100644
--- a/war/WEB-INF/appengine-web.xml
+++ b/war/WEB-INF/appengine-web.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
 	<application>skillmaps</application>
-	<version>stable-001</version>
+	<version>fix-722</version>
 	<precompilation-enabled>true</precompilation-enabled>
 
 	<system-properties>
-- 
1.6.5.1.1367.gcd48

