Subversion Repository Public Repository

litesoft

Diff Revisions 479 vs 480 for /trunk/GWT_Sandbox/Prioritizer/src/org/litesoft/prioritizer/client/boviews/UserViewDataProvider.java

Diff revisions: vs.
  @@ -1,14 +1,16 @@
1 1 package org.litesoft.prioritizer.client.boviews;
2 2
3 + import org.litesoft.GWT.client.context.*;
3 4 import org.litesoft.GWT.client.view.*;
4 5 import org.litesoft.bo.views.*;
5 6 import org.litesoft.bo.views.caching.*;
6 7 import org.litesoft.bo.views.communication.*;
7 8 import org.litesoft.core.*;
8 9 import org.litesoft.core.util.*;
10 + import org.litesoft.prioritizer.client.accessors.*;
11 + import org.litesoft.security.*;
9 12
10 - public class UserViewDataProvider extends Prioritizer_TypedVoDataProvider<UserView> implements UserViewNames,
11 - LoginServerStateChecker
13 + public class UserViewDataProvider extends SecurityUserViewDataProvider<UserView>
12 14 {
13 15 private static UserViewDataProvider sInstance = null;
14 16
  @@ -28,166 +30,20 @@
28 30 }
29 31
30 32 @Override
31 - public void checkServerLogin( final SimpleDataProviderCallBack pCallBack )
33 + protected SecurityUserView createWithRestrictedResourceView( SecurityRestrictedResourceView pRestrictedResourceView )
32 34 {
33 - getCScomm().requestFunctionFetchRow( this, null, //
34 - new VOCSrequestFunctionFetchRow( UserView.class, //
35 - UserViewAbstractServerFunctionFetchCurrentLoginUser.REG_ID ), //
36 - new FetchRowDataProviderCallBack<UserView>()
37 - {
38 - @Override
39 - public void success( UserView pRow )
40 - {
41 - updateContext( pRow );
42 - pCallBack.error( null );
43 - }
44 -
45 - @Override
46 - public void error( String pError )
47 - {
48 - pCallBack.error( pError );
49 - }
50 - } );
51 - }
52 -
53 - public void changePassword( UserView pUserView, final SimpleDataProviderCallBack pCallBack )
54 - {
55 - if ( cursoryPasswordCheck( pUserView.getCurrentPassword(), aCurrentPassword, pCallBack ) )
56 - {
57 - if ( cursoryPasswordCheck( pUserView.getNewPassword(), aNewPassword, pCallBack ) )
58 - {
59 - if ( cursoryPasswordCheck( pUserView.getConfirmPassword(), aConfirmPassword, pCallBack ) )
60 - {
61 - getCScomm().requestFunctionFetchRow( this, null, //
62 - new VOCSrequestFunctionFetchRow( UserView.class, //
63 - UserViewAbstractServerFunctionChangePassword.REG_ID, //
64 - pUserView ), new FetchRowDataProviderCallBack<UserView>()
65 - {
66 - @Override
67 - public void success( UserView pRow )
68 - {
69 - updateContext( pRow );
70 - pCallBack.error( null );
71 - }
72 -
73 - @Override
74 - public void error( String pError )
75 - {
76 - pCallBack.error( pError );
77 - }
78 - } );
79 - }
80 - }
81 - }
82 - }
83 -
84 - public void validatePassword( UserView pUserView, SimpleDataProviderCallBack pCallBack )
85 - {
86 - if ( cursoryPasswordCheck( pUserView.getCurrentPassword(), aCurrentPassword, pCallBack ) )
87 - {
88 - getCScomm().requestFunctionSimple( new VOCSrequestFunctionSimple( UserView.class, //
89 - UserViewAbstractServerFunctionValidatePassword.REG_ID, //
90 - pUserView ), pCallBack );
91 - }
92 - }
93 -
94 - public void attemptLogin( UserView pUserView, final SimpleDataProviderCallBack pCallBack )
95 - {
96 - if ( cursoryEmailCheck( pUserView.getLogonEmail(), aLogonEmail, pCallBack ) )
97 - {
98 - if ( cursoryPasswordCheck( pUserView.getCurrentPassword(), aCurrentPassword, pCallBack ) )
99 - {
100 - getCScomm().requestFunctionFetchRow( this, null, //
101 - new VOCSrequestFunctionFetchRow( UserView.class, //
102 - UserViewAbstractServerFunctionLogin.REG_ID, //
103 - pUserView ), new FetchRowDataProviderCallBack<UserView>()
104 - {
105 - @Override
106 - public void success( UserView pRow )
107 - {
108 - updateContext( pRow );
109 - pCallBack.error( null );
110 - }
111 -
112 - @Override
113 - public void error( String pError )
114 - {
115 - pCallBack.error( pError );
116 - }
117 - } );
118 - }
119 - }
120 - }
121 -
122 - public void logoutUser()
123 - {
124 - ClientContext.get().get( CurrentUserViewAccessor.class ).setUser( null );
125 - getCScomm().requestFunctionSimple( new VOCSrequestFunctionSimple( UserView.class.getName(), UserViewAbstractServerFunctionLogout.REG_ID ), null );
126 - }
127 -
128 - public void nextDemoUser( final SimpleDataProviderCallBack pCallBack )
129 - {
130 - getCScomm().requestFunctionFetchRow( this, null, //
131 - new VOCSrequestFunctionFetchRow( UserView.class, //
132 - UserViewAbstractServerFunctionNextDemoLoginUser.REG_ID ), //
133 - new FetchRowDataProviderCallBack<UserView>()
134 - {
135 - @Override
136 - public void success( UserView pRow )
137 - {
138 - updateContext( pRow );
139 - pCallBack.error( null );
140 - }
141 -
142 - @Override
143 - public void error( String pError )
144 - {
145 - pCallBack.error( pError );
146 - }
147 - } );
148 - }
149 -
150 - public void attemptSwitchToRestrictedResource( RestrictedResourceView pRestrictedResourceView, final SimpleDataProviderCallBack pCallBack )
151 - {
152 - UtilsCommon.assertNotNull( "RestrictedResource", pRestrictedResourceView );
153 - RestrictedResourceView zRestrictedResource = ClientContext.get().get( CurrentRestrictedResourceViewAccessor.class ).getRestrictedResource();
154 - if ( pRestrictedResourceView.equals( zRestrictedResource ) )
155 - {
156 - pCallBack.error( "Already at RestrictedResource: " + zRestrictedResource );
157 - return;
158 - }
159 - UserView zUser = UserView.createNew();
35 + UserView zUser = new UserView( false, null );
160 36 zUser.setCurrentRestrictedResource( pRestrictedResourceView );
161 - getCScomm().requestFunctionFetchRow( this, null, //
162 - new VOCSrequestFunctionFetchRow( UserView.class, //
163 - UserViewAbstractServerFunctionSwitchRestrictedResources.REG_ID, //
164 - zUser ), new FetchRowDataProviderCallBack<UserView>()
165 - {
166 - @Override
167 - public void success( UserView pRow )
168 - {
169 - updateContext( pRow );
170 - pCallBack.error( null );
171 - }
172 -
173 - @Override
174 - public void error( String pError )
175 - {
176 - pCallBack.error( pError );
177 - }
178 - } );
37 + zUser.initialize();
38 + return zUser;
179 39 }
180 40
181 - public void validateLogonEmailAvailable( String pLogonEmail, FetchRowDataProviderCallBack<UserView> pCallBack )
41 + @Override
42 + protected SecurityUserView createWithLogonEmail( String pLogonEmail )
182 43 {
183 - if ( cursoryEmailCheck( pLogonEmail, aLogonEmail, pCallBack ) )
184 - {
185 - UserView zUserView = new UserView( false, null );
186 - zUserView.setLogonEmail( pLogonEmail );
187 - zUserView.initialize();
188 - getCScomm().requestFunctionFetchRow( this, null, //
189 - new VOCSrequestFunctionFetchRow( UserView.class, //
190 - UserViewAbstractServerFunctionValidateLogonEmailAvailable.REG_ID, zUserView ), pCallBack );
191 - }
44 + UserView zUser = new UserView( false, null );
45 + zUser.setLogonEmail( pLogonEmail );
46 + zUser.initialize();
47 + return zUser;
192 48 }
193 49 }