From 7d689d7fe6a660729ff098367be1db06d4872319 Mon Sep 17 00:00:00 2001
From: yusuke.kokubo <yusuke.kokubo@gmail.com>
Date: Thu, 12 May 2011 11:21:40 +0900
Subject: [PATCH] =?UTF-8?q?=E3=83=AD=E3=82=B0=E3=82=A4=E3=83=B3=E5=BE=8C=E3=81=AB=E3=82=82=E3=81=A8=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    |    1 -
 .../skillmaps/client/service/AccountService.java   |    2 +
 .../client/service/AccountServiceAsync.java        |    2 +
 src/com/appspot/skillmaps/client/ui/Header.java    |    4 +-
 src/com/appspot/skillmaps/client/ui/Header.ui.xml  |    7 ++--
 .../appspot/skillmaps/client/ui/SigninAnchor.java  |   35 ++++++++++++++++++++
 .../skillmaps/client/ui/SigninGuidance.java        |    4 +--
 .../skillmaps/client/ui/SigninGuidance.ui.xml      |    5 ++-
 .../server/service/AccountServiceImpl.java         |    8 +++-
 src/com/appspot/skillmaps/shared/model/Login.java  |    9 -----
 10 files changed, 55 insertions(+), 22 deletions(-)
 create mode 100644 src/com/appspot/skillmaps/client/ui/SigninAnchor.java

diff --git a/src/com/appspot/skillmaps/client/Skillmaps.java b/src/com/appspot/skillmaps/client/Skillmaps.java
index 98bb673..fe558f0 100644
--- a/src/com/appspot/skillmaps/client/Skillmaps.java
+++ b/src/com/appspot/skillmaps/client/Skillmaps.java
@@ -38,7 +38,6 @@ public class Skillmaps implements EntryPoint {
                     login.setEmailAddress(result.getEmailAddress());
                     login.setKey(result.getKey());
                     login.setLoggedIn(result.isLoggedIn());
-                    login.setLoginUrl(result.getLoginUrl());
                     login.setLogoutUrl(result.getLogoutUrl());
                     login.setNickname(result.getNickname());
                     login.setProfile(result.getProfile());
diff --git a/src/com/appspot/skillmaps/client/service/AccountService.java b/src/com/appspot/skillmaps/client/service/AccountService.java
index f8879ea..a4d364e 100644
--- a/src/com/appspot/skillmaps/client/service/AccountService.java
+++ b/src/com/appspot/skillmaps/client/service/AccountService.java
@@ -28,4 +28,6 @@ public interface AccountService extends RemoteService {
 
     Profile[] getRecentEntriedUsers();
 
+    String getSignUrl(String backUrl);
+
 }
diff --git a/src/com/appspot/skillmaps/client/service/AccountServiceAsync.java b/src/com/appspot/skillmaps/client/service/AccountServiceAsync.java
index 0d86a17..7fbeb96 100644
--- a/src/com/appspot/skillmaps/client/service/AccountServiceAsync.java
+++ b/src/com/appspot/skillmaps/client/service/AccountServiceAsync.java
@@ -24,4 +24,6 @@ public interface AccountServiceAsync {
 
     void getRecentEntriedUsers(AsyncCallback<Profile[]> callback);
 
+    void getSignUrl(String backUrl, AsyncCallback<String> callback);
+
 }
diff --git a/src/com/appspot/skillmaps/client/ui/Header.java b/src/com/appspot/skillmaps/client/ui/Header.java
index e5a5a85..f0f43c1 100644
--- a/src/com/appspot/skillmaps/client/ui/Header.java
+++ b/src/com/appspot/skillmaps/client/ui/Header.java
@@ -33,7 +33,7 @@ public class Header extends Composite {
     Label nickname;
 
     @UiField
-    Anchor signin;
+    SigninAnchor signin;
 
     @UiField
     Anchor signout;
@@ -60,8 +60,8 @@ public class Header extends Composite {
             signPanel.addStyleName(style.signIn());
         } else {
             nickname.setText("");
-            signin.setHref(login.getLoginUrl());
             signout.setHref(login.getLogoutUrl());
+            
             signPanel.removeStyleName(style.loading());
             signPanel.addStyleName(style.signOut());
         }
diff --git a/src/com/appspot/skillmaps/client/ui/Header.ui.xml b/src/com/appspot/skillmaps/client/ui/Header.ui.xml
index ab8272d..e0ba276 100644
--- a/src/com/appspot/skillmaps/client/ui/Header.ui.xml
+++ b/src/com/appspot/skillmaps/client/ui/Header.ui.xml
@@ -1,6 +1,7 @@
 <!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
 <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
-	xmlns:g="urn:import:com.google.gwt.user.client.ui">
+	xmlns:g="urn:import:com.google.gwt.user.client.ui"
+	xmlns:sm="urn:import:com.appspot.skillmaps.client.ui">
 	<ui:style type="com.appspot.skillmaps.client.ui.Header.Style">
 		.menu {
 			float: left;
@@ -171,8 +172,8 @@
 			<g:HorizontalPanel ui:field="signPanel" styleName="{style.sign}">
 				<g:Label addStyleNames="{style.nickname}" ui:field="nickname"></g:Label>
 				<g:Label styleName="{style.demiliter}">|</g:Label>
-				<g:Anchor addStyleNames="{style.signinlink}" ui:field="signin">Sign
-					In</g:Anchor>
+				<sm:SigninAnchor addStyleNames="{style.signinlink}" ui:field="signin">Sign
+					In</sm:SigninAnchor>
 				<g:Anchor addStyleNames="{style.signoutlink}" ui:field="signout">Sign
 					Out</g:Anchor>
 			</g:HorizontalPanel>
diff --git a/src/com/appspot/skillmaps/client/ui/SigninAnchor.java b/src/com/appspot/skillmaps/client/ui/SigninAnchor.java
new file mode 100644
index 0000000..2fb191a
--- /dev/null
+++ b/src/com/appspot/skillmaps/client/ui/SigninAnchor.java
@@ -0,0 +1,35 @@
+package com.appspot.skillmaps.client.ui;
+
+import com.appspot.skillmaps.client.service.AccountService;
+import com.appspot.skillmaps.client.service.AccountServiceAsync;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.Anchor;
+
+public class SigninAnchor extends Anchor {
+
+    private final AccountServiceAsync service = GWT.create(AccountService.class);
+
+    public SigninAnchor() {
+        setHref("#");
+        addClickHandler(new ClickHandler() {
+            @Override
+            public void onClick(ClickEvent event) {
+                service.getSignUrl(GWT.getHostPageBaseURL() + Window.Location.getQueryString() + Window.Location.getHash(),
+                    new AsyncCallback<String>() {
+                        @Override
+                        public void onSuccess(String result) {
+                            Window.Location.replace(result);
+                        }
+                        
+                        @Override
+                        public void onFailure(Throwable caught) {
+                        }
+                    });
+            }
+        });
+    }
+}
diff --git a/src/com/appspot/skillmaps/client/ui/SigninGuidance.java b/src/com/appspot/skillmaps/client/ui/SigninGuidance.java
index a555f96..5781300 100644
--- a/src/com/appspot/skillmaps/client/ui/SigninGuidance.java
+++ b/src/com/appspot/skillmaps/client/ui/SigninGuidance.java
@@ -6,7 +6,6 @@ import com.appspot.skillmaps.shared.model.Login;
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.uibinder.client.UiBinder;
 import com.google.gwt.uibinder.client.UiField;
-import com.google.gwt.user.client.ui.Anchor;
 import com.google.gwt.user.client.ui.Composite;
 import com.google.gwt.user.client.ui.Label;
 import com.google.gwt.user.client.ui.Widget;
@@ -24,7 +23,7 @@ public class SigninGuidance extends Composite implements SigninGuidanceDisplay{
     Label guidance;
 
     @UiField
-    Anchor signin;
+    SigninAnchor signin;
 
     private Presenter presenter;
 
@@ -32,7 +31,6 @@ public class SigninGuidance extends Composite implements SigninGuidanceDisplay{
     public SigninGuidance(Login login) {
         initWidget(uiBinder.createAndBindUi(this));
         guidance.setText("SkillMapsは自分のスキルを他人が評価してくれるソーシャル他人評価サービスです.サインインすれば誰でもすぐに使えます!");
-        signin.setHref(login.getLoginUrl());
     }
 
 
diff --git a/src/com/appspot/skillmaps/client/ui/SigninGuidance.ui.xml b/src/com/appspot/skillmaps/client/ui/SigninGuidance.ui.xml
index 8ab3a7a..733d3eb 100644
--- a/src/com/appspot/skillmaps/client/ui/SigninGuidance.ui.xml
+++ b/src/com/appspot/skillmaps/client/ui/SigninGuidance.ui.xml
@@ -1,10 +1,11 @@
 <!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
 <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
-	xmlns:g="urn:import:com.google.gwt.user.client.ui">
+	xmlns:g="urn:import:com.google.gwt.user.client.ui"
+	xmlns:sm="urn:import:com.appspot.skillmaps.client.ui">
 	<ui:style>
 	</ui:style>
 	<g:VerticalPanel>
 		<g:Label ui:field="guidance"></g:Label>
-		<g:Anchor ui:field="signin">Sign in</g:Anchor>
+		<sm:SigninAnchor ui:field="signin">Sign in</sm:SigninAnchor>
 	</g:VerticalPanel>
 </ui:UiBinder>
diff --git a/src/com/appspot/skillmaps/server/service/AccountServiceImpl.java b/src/com/appspot/skillmaps/server/service/AccountServiceImpl.java
index 6bdd419..21787ce 100644
--- a/src/com/appspot/skillmaps/server/service/AccountServiceImpl.java
+++ b/src/com/appspot/skillmaps/server/service/AccountServiceImpl.java
@@ -55,7 +55,6 @@ public class AccountServiceImpl implements AccountService {
             login.setProfile(p);
         } else {
             login.setLoggedIn(false);
-            login.setLoginUrl(userService.createLoginURL(requestUri));
         }
 
         return login;
@@ -173,6 +172,12 @@ public class AccountServiceImpl implements AccountService {
         return resultDto;
     }
 
+    @Override
+    public String getSignUrl(String backUrl) {
+        UserService us = UserServiceFactory.getUserService();
+        return us.createLoginURL(backUrl);
+    }
+    
     private UserListResultDto createUserListResultDto(
             S3QueryResultList<Profile> result) {
         UserListResultDto resultDto = new UserListResultDto();
@@ -222,5 +227,4 @@ public class AccountServiceImpl implements AccountService {
     }
 
 
-
 }
diff --git a/src/com/appspot/skillmaps/shared/model/Login.java b/src/com/appspot/skillmaps/shared/model/Login.java
index fa01eb1..30f9851 100644
--- a/src/com/appspot/skillmaps/shared/model/Login.java
+++ b/src/com/appspot/skillmaps/shared/model/Login.java
@@ -11,7 +11,6 @@ public class Login implements Serializable {
     private Long version;
 
     private boolean loggedIn = false;
-    private String loginUrl;
     private String logoutUrl;
     private String emailAddress;
     private String nickname;
@@ -73,14 +72,6 @@ public class Login implements Serializable {
         this.loggedIn = loggedIn;
     }
 
-    public String getLoginUrl() {
-        return loginUrl;
-    }
-
-    public void setLoginUrl(String loginUrl) {
-        this.loginUrl = loginUrl;
-    }
-
     public String getLogoutUrl() {
         return logoutUrl;
     }
-- 
1.6.5.1.1367.gcd48

