Status: | Merged |
---|---|
Merged at revision: | 102 |
Proposed branch: | lp:~mugle-dev/mugle/ui |
Merge into: | lp:mugle |
Prerequisite: | lp:~mugle-dev/mugle/dev-api |
Diff against target: |
2425 lines (+1111/-329) 46 files modified
src/au/edu/unimelb/csse/mugle/client/ClientService.java (+4/-2) src/au/edu/unimelb/csse/mugle/client/ClientServiceAsync.java (+1/-1) src/au/edu/unimelb/csse/mugle/client/Mugle.java (+68/-76) src/au/edu/unimelb/csse/mugle/client/platform/AdminService.java (+2/-0) src/au/edu/unimelb/csse/mugle/client/platform/AdminServiceAsync.java (+2/-0) src/au/edu/unimelb/csse/mugle/client/platform/DeveloperService.java (+3/-1) src/au/edu/unimelb/csse/mugle/client/platform/DeveloperServiceAsync.java (+2/-0) src/au/edu/unimelb/csse/mugle/client/platform/GuestService.java (+7/-2) src/au/edu/unimelb/csse/mugle/client/platform/GuestServiceAsync.java (+5/-2) src/au/edu/unimelb/csse/mugle/client/ui/MugleDialogBox.java (+104/-0) src/au/edu/unimelb/csse/mugle/client/ui/MugleUiBuilder.java (+192/-0) src/au/edu/unimelb/csse/mugle/server/ClientServiceImpl.java (+2/-3) src/au/edu/unimelb/csse/mugle/server/DataTestServiceImpl.java (+11/-2) src/au/edu/unimelb/csse/mugle/server/GameFileServer.java (+94/-0) src/au/edu/unimelb/csse/mugle/server/api/BadgeServiceImpl.java (+0/-2) src/au/edu/unimelb/csse/mugle/server/api/HighscoreServiceImpl.java (+1/-9) src/au/edu/unimelb/csse/mugle/server/api/KeyValueServiceImpl.java (+1/-11) src/au/edu/unimelb/csse/mugle/server/api/UserServiceImpl.java (+2/-18) src/au/edu/unimelb/csse/mugle/server/model/AchievementGetter.java (+6/-3) src/au/edu/unimelb/csse/mugle/server/model/DevTeamGetter.java (+6/-4) src/au/edu/unimelb/csse/mugle/server/model/GameFileData.java (+6/-31) src/au/edu/unimelb/csse/mugle/server/model/GameFileGetter.java (+116/-0) src/au/edu/unimelb/csse/mugle/server/model/GameVersionData.java (+7/-33) src/au/edu/unimelb/csse/mugle/server/model/GameVersionGetter.java (+107/-0) src/au/edu/unimelb/csse/mugle/server/model/KeyValuePairGetter.java (+13/-9) src/au/edu/unimelb/csse/mugle/server/model/ModelDataClass.java (+12/-0) src/au/edu/unimelb/csse/mugle/server/model/ModelWrapper.java (+55/-6) src/au/edu/unimelb/csse/mugle/server/model/UserAchievementGetter.java (+12/-6) src/au/edu/unimelb/csse/mugle/server/model/UserGameProfileGetter.java (+13/-7) src/au/edu/unimelb/csse/mugle/server/model/UserGetter.java (+36/-14) src/au/edu/unimelb/csse/mugle/server/model/annotations/UserLevel.java (+2/-2) src/au/edu/unimelb/csse/mugle/server/platform/DeveloperServiceImpl.java (+1/-1) src/au/edu/unimelb/csse/mugle/server/platform/GuestServiceImpl.java (+14/-2) src/au/edu/unimelb/csse/mugle/shared/model/DataServiceAsync.java (+1/-1) src/au/edu/unimelb/csse/mugle/shared/model/GameFile.java (+6/-14) src/au/edu/unimelb/csse/mugle/shared/model/GameVersion.java (+3/-3) src/au/edu/unimelb/csse/mugle/shared/model/ModelClass.java (+7/-4) src/au/edu/unimelb/csse/mugle/shared/model/Role.java (+1/-1) src/au/edu/unimelb/csse/mugle/shared/model/annotations/MugleDataWrapper.java (+6/-6) src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameFileNotExists.java (+22/-0) src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameNotExists.java (+4/-0) src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/ServerException.java (+34/-0) war/Mugle.css (+77/-22) war/Mugle.html (+32/-23) war/MugleIE6.css (+3/-0) war/WEB-INF/web.xml (+8/-8) |
To merge this branch: | bzr merge lp:~mugle-dev/mugle/ui |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Matt Giuca | Approve | ||
Review via email: mp+59455@code.launchpad.net |
Commit message
Description of the change
Adds some new UI capabilities. Merge because it's too hard to separate changes between branches and trunk isn't being worked on anyway.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === renamed file 'src/au/edu/unimelb/csse/mugle/client/LoginService.java' => 'src/au/edu/unimelb/csse/mugle/client/ClientService.java' | |||
2 | --- src/au/edu/unimelb/csse/mugle/client/LoginService.java 2011-03-06 10:21:39 +0000 | |||
3 | +++ src/au/edu/unimelb/csse/mugle/client/ClientService.java 2011-04-29 07:02:27 +0000 | |||
4 | @@ -16,10 +16,12 @@ | |||
5 | 16 | */ | 16 | */ |
6 | 17 | package au.edu.unimelb.csse.mugle.client; | 17 | package au.edu.unimelb.csse.mugle.client; |
7 | 18 | 18 | ||
8 | 19 | import au.edu.unimelb.csse.mugle.client.LoginInfo; | ||
9 | 20 | |||
10 | 19 | import com.google.gwt.user.client.rpc.RemoteService; | 21 | import com.google.gwt.user.client.rpc.RemoteService; |
11 | 20 | import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; | 22 | import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; |
12 | 21 | 23 | ||
15 | 22 | @RemoteServiceRelativePath("login") | 24 | @RemoteServiceRelativePath("client") |
16 | 23 | public interface LoginService extends RemoteService { | 25 | public interface ClientService extends RemoteService { |
17 | 24 | LoginInfo login(String requestUri); | 26 | LoginInfo login(String requestUri); |
18 | 25 | } | 27 | } |
19 | 26 | 28 | ||
20 | === renamed file 'src/au/edu/unimelb/csse/mugle/client/LoginServiceAsync.java' => 'src/au/edu/unimelb/csse/mugle/client/ClientServiceAsync.java' | |||
21 | --- src/au/edu/unimelb/csse/mugle/client/LoginServiceAsync.java 2011-03-06 10:21:39 +0000 | |||
22 | +++ src/au/edu/unimelb/csse/mugle/client/ClientServiceAsync.java 2011-04-29 07:02:27 +0000 | |||
23 | @@ -18,6 +18,6 @@ | |||
24 | 18 | 18 | ||
25 | 19 | import com.google.gwt.user.client.rpc.AsyncCallback; | 19 | import com.google.gwt.user.client.rpc.AsyncCallback; |
26 | 20 | 20 | ||
28 | 21 | public interface LoginServiceAsync { | 21 | public interface ClientServiceAsync { |
29 | 22 | void login(String requestUri, AsyncCallback<LoginInfo> async); | 22 | void login(String requestUri, AsyncCallback<LoginInfo> async); |
30 | 23 | } | 23 | } |
31 | 24 | 24 | ||
32 | === modified file 'src/au/edu/unimelb/csse/mugle/client/Mugle.java' | |||
33 | --- src/au/edu/unimelb/csse/mugle/client/Mugle.java 2011-04-08 11:51:46 +0000 | |||
34 | +++ src/au/edu/unimelb/csse/mugle/client/Mugle.java 2011-04-29 07:02:27 +0000 | |||
35 | @@ -1,20 +1,17 @@ | |||
36 | 1 | package au.edu.unimelb.csse.mugle.client; | 1 | package au.edu.unimelb.csse.mugle.client; |
37 | 2 | 2 | ||
38 | 3 | import au.edu.unimelb.csse.mugle.client.ui.MugleUiBuilder; | ||
39 | 4 | |||
40 | 3 | import com.google.gwt.core.client.EntryPoint; | 5 | import com.google.gwt.core.client.EntryPoint; |
41 | 4 | import com.google.gwt.core.client.GWT; | 6 | import com.google.gwt.core.client.GWT; |
44 | 5 | import com.google.gwt.event.logical.shared.ResizeEvent; | 7 | import com.google.gwt.user.client.Element; |
45 | 6 | import com.google.gwt.event.logical.shared.ResizeHandler; | 8 | import com.google.gwt.event.dom.client.ClickEvent; |
46 | 9 | import com.google.gwt.event.dom.client.ClickHandler; | ||
47 | 7 | import com.google.gwt.user.client.DOM; | 10 | import com.google.gwt.user.client.DOM; |
48 | 8 | import com.google.gwt.user.client.Window; | ||
49 | 9 | import com.google.gwt.user.client.rpc.AsyncCallback; | 11 | import com.google.gwt.user.client.rpc.AsyncCallback; |
50 | 12 | import com.google.gwt.user.client.ui.Button; | ||
51 | 10 | import com.google.gwt.user.client.ui.Grid; | 13 | import com.google.gwt.user.client.ui.Grid; |
52 | 11 | import com.google.gwt.user.client.ui.HTML; | ||
53 | 12 | import com.google.gwt.user.client.ui.HorizontalPanel; | ||
54 | 13 | import com.google.gwt.user.client.ui.Label; | ||
55 | 14 | import com.google.gwt.user.client.ui.RootPanel; | 14 | import com.google.gwt.user.client.ui.RootPanel; |
56 | 15 | import com.google.gwt.user.client.ui.StackPanel; | ||
57 | 16 | import com.google.gwt.user.client.ui.VerticalPanel; | ||
58 | 17 | import com.google.gwt.user.client.ui.Widget; | ||
59 | 18 | 15 | ||
60 | 19 | /** | 16 | /** |
61 | 20 | * Entry point classes define <code>onModuleLoad()</code>. | 17 | * Entry point classes define <code>onModuleLoad()</code>. |
62 | @@ -27,13 +24,11 @@ | |||
63 | 27 | private static final String SERVER_ERROR = "An error occurred while " | 24 | private static final String SERVER_ERROR = "An error occurred while " |
64 | 28 | + "attempting to contact the server. Please check your network " | 25 | + "attempting to contact the server. Please check your network " |
65 | 29 | + "connection and try again."; | 26 | + "connection and try again."; |
69 | 30 | 27 | ||
67 | 31 | private final DataTestServiceAsync dataTestService = GWT.create(DataTestService.class); | ||
68 | 32 | |||
70 | 33 | private RootPanel mainPanel = null; | 28 | private RootPanel mainPanel = null; |
71 | 34 | 29 | ||
72 | 35 | private AuthenticatedUser authUser = new AuthenticatedUser(); | 30 | private AuthenticatedUser authUser = new AuthenticatedUser(); |
74 | 36 | 31 | ||
75 | 37 | /** | 32 | /** |
76 | 38 | * This is the entry point method. | 33 | * This is the entry point method. |
77 | 39 | * Checks if logged in, if you are, runs the standard code for page, | 34 | * Checks if logged in, if you are, runs the standard code for page, |
78 | @@ -42,11 +37,13 @@ | |||
79 | 42 | @Override | 37 | @Override |
80 | 43 | public void onModuleLoad() { | 38 | public void onModuleLoad() { |
81 | 44 | 39 | ||
83 | 45 | this.getStaticPanels(); | 40 | this.mainPanel = RootPanel.get("main-panel"); |
84 | 41 | Element element = RootPanel.get("error-display").getElement(); | ||
85 | 42 | DOM.removeChild(RootPanel.get("container").getElement(), element); | ||
86 | 46 | 43 | ||
87 | 47 | //Check login status using login service. | 44 | //Check login status using login service. |
90 | 48 | LoginServiceAsync loginService = GWT.create(LoginService.class); | 45 | ClientServiceAsync clientService = GWT.create(ClientService.class); |
91 | 49 | loginService.login(GWT.getHostPageBaseURL(), new AsyncCallback<LoginInfo>() { | 46 | clientService.login(GWT.getHostPageBaseURL(), new AsyncCallback<LoginInfo>() { |
92 | 50 | 47 | ||
93 | 51 | public void onFailure(Throwable error) { | 48 | public void onFailure(Throwable error) { |
94 | 52 | System.err.print(error.getMessage()); | 49 | System.err.print(error.getMessage()); |
95 | @@ -61,80 +58,75 @@ | |||
96 | 61 | }); | 58 | }); |
97 | 62 | 59 | ||
98 | 63 | } | 60 | } |
122 | 64 | 61 | ||
100 | 65 | private void getStaticPanels() { | ||
101 | 66 | |||
102 | 67 | mainPanel = RootPanel.get("main-panel"); | ||
103 | 68 | |||
104 | 69 | /* | ||
105 | 70 | final RootPanel topPanel = RootPanel.get("user-panel"); | ||
106 | 71 | final RootPanel footer = RootPanel.get("footer"); | ||
107 | 72 | final RootPanel errPanel = RootPanel.get("error-display"); | ||
108 | 73 | |||
109 | 74 | Window.addResizeHandler(new ResizeHandler() { | ||
110 | 75 | public void onResize(ResizeEvent event) { | ||
111 | 76 | int h = topPanel.getOffsetHeight() + footer.getOffsetHeight() + errPanel.getOffsetHeight(); | ||
112 | 77 | int height = event.getHeight() - h - 10; | ||
113 | 78 | if (height < 200) { height = 200; } | ||
114 | 79 | mainPanel.setHeight(height + "px"); | ||
115 | 80 | } | ||
116 | 81 | }); | ||
117 | 82 | |||
118 | 83 | */ | ||
119 | 84 | |||
120 | 85 | } | ||
121 | 86 | |||
123 | 87 | private void arrangeUI() { | 62 | private void arrangeUI() { |
124 | 88 | 63 | ||
125 | 89 | if (this.authUser.isLoggedIn()) { | 64 | if (this.authUser.isLoggedIn()) { |
126 | 90 | 65 | ||
127 | 91 | Grid userPanel = new Grid(1,3); | 66 | Grid userPanel = new Grid(1,3); |
134 | 92 | RootPanel.get("user-panel-holder").add(userPanel); | 67 | DOM.getElementById("user-panel-holder").appendChild(userPanel.getElement()); |
135 | 93 | 68 | ||
136 | 94 | RootPanel mainPanel = RootPanel.get("main-panel"); | 69 | //this.mainPanel = RootPanel.get("main-panel"); |
137 | 95 | 70 | ||
138 | 96 | this.arrangeUserPanel(userPanel); | 71 | MugleUiBuilder.arrangeUserPanel(userPanel, this.authUser); |
139 | 97 | this.arrangeMainPanel(mainPanel); | 72 | MugleUiBuilder.arrangeMainPanel(this.mainPanel); |
140 | 98 | 73 | ||
141 | 99 | } else { | 74 | } else { |
142 | 100 | 75 | ||
143 | 101 | this.mainPanel.add(this.authUser.resetLoginPanel()); | 76 | this.mainPanel.add(this.authUser.resetLoginPanel()); |
144 | 102 | 77 | ||
145 | 78 | |||
146 | 79 | // debugging | ||
147 | 80 | |||
148 | 81 | //final MugleDialogBox dialog = new MugleDialogBox("Data Population"); | ||
149 | 82 | final Button b = new Button("Populate Data"); | ||
150 | 83 | |||
151 | 84 | //dialog.setReturnFocus(b); | ||
152 | 85 | |||
153 | 86 | b.addStyleName("sendButton"); | ||
154 | 87 | b.addClickHandler(new ClickHandler() { | ||
155 | 88 | |||
156 | 89 | DataTestServiceAsync dataTestService = GWT.create(DataTestService.class); | ||
157 | 90 | |||
158 | 91 | @Override | ||
159 | 92 | public void onClick(ClickEvent event) { | ||
160 | 93 | |||
161 | 94 | dataTestService.populateDatastore(new AsyncCallback<String>() { | ||
162 | 95 | |||
163 | 96 | @Override | ||
164 | 97 | public void onFailure(Throwable caught) { | ||
165 | 98 | System.err.println("failed"); | ||
166 | 99 | b.setEnabled(true); | ||
167 | 100 | b.setText("Try again! Populate Database"); | ||
168 | 101 | //dialog.setBody(new HTML(SERVER_ERROR)); | ||
169 | 102 | //dialog.center(); | ||
170 | 103 | //dialog.show(); | ||
171 | 104 | } | ||
172 | 105 | |||
173 | 106 | @Override | ||
174 | 107 | public void onSuccess(String result) { | ||
175 | 108 | System.err.println("success"); | ||
176 | 109 | b.setText("Database successfully populated"); | ||
177 | 110 | //dialog.setBody(new HTML(result)); | ||
178 | 111 | //dialog.show(); | ||
179 | 112 | //dialog.center(); | ||
180 | 113 | } | ||
181 | 114 | |||
182 | 115 | }); | ||
183 | 116 | |||
184 | 117 | b.setEnabled(false); | ||
185 | 118 | b.setText("Processing"); | ||
186 | 119 | |||
187 | 120 | } | ||
188 | 121 | |||
189 | 122 | }); | ||
190 | 123 | |||
191 | 124 | this.mainPanel.add(b); | ||
192 | 125 | |||
193 | 103 | } | 126 | } |
194 | 104 | 127 | ||
195 | 105 | } | 128 | } |
196 | 106 | 129 | ||
197 | 107 | private void arrangeUserPanel(Grid userPanel) { | ||
198 | 108 | |||
199 | 109 | RootPanel.get("user-panel-title").add(new HTML("<b>MUGLE</b>")); | ||
200 | 110 | userPanel.setWidget(0, 0, new HTML("<b>" + this.authUser.getLoginInfo().getEmailAddress() + "</b>")); | ||
201 | 111 | userPanel.setWidget(0, 1, new HTML("|")); | ||
202 | 112 | userPanel.setWidget(0, 2, this.authUser.getSignOutLink()); | ||
203 | 113 | |||
204 | 114 | } | ||
205 | 115 | |||
206 | 116 | private void arrangeMainPanel(RootPanel mainPanel) { | ||
207 | 117 | |||
208 | 118 | HorizontalPanel hp = new HorizontalPanel(); | ||
209 | 119 | |||
210 | 120 | // left panel | ||
211 | 121 | StackPanel sp = new StackPanel(); | ||
212 | 122 | //sp.setWidth("200px"); | ||
213 | 123 | DOM.setElementAttribute(sp.getElement(), "id", "tools-panel"); | ||
214 | 124 | |||
215 | 125 | |||
216 | 126 | sp.setStackText(0, "Topic", false); | ||
217 | 127 | |||
218 | 128 | sp.insert(new HTML("test"), 0); | ||
219 | 129 | sp.insert(new HTML("test 2"), 1); | ||
220 | 130 | sp.insert(new HTML("test 3"), 2); | ||
221 | 131 | |||
222 | 132 | hp.insert(sp, 0); | ||
223 | 133 | hp.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT); | ||
224 | 134 | mainPanel.add(hp); | ||
225 | 135 | |||
226 | 136 | } | ||
227 | 137 | |||
228 | 138 | /* | 130 | /* |
229 | 139 | private void loadDataTest() { | 131 | private void loadDataTest() { |
230 | 140 | //Set up sign out hyperlink. | 132 | //Set up sign out hyperlink. |
231 | 141 | 133 | ||
232 | === modified file 'src/au/edu/unimelb/csse/mugle/client/platform/AdminService.java' | |||
233 | --- src/au/edu/unimelb/csse/mugle/client/platform/AdminService.java 2011-03-20 11:06:48 +0000 | |||
234 | +++ src/au/edu/unimelb/csse/mugle/client/platform/AdminService.java 2011-04-29 07:02:27 +0000 | |||
235 | @@ -41,6 +41,8 @@ | |||
236 | 41 | 41 | ||
237 | 42 | boolean banUser(Long id) throws UserNotExists, UserPrivilegeException; | 42 | boolean banUser(Long id) throws UserNotExists, UserPrivilegeException; |
238 | 43 | 43 | ||
239 | 44 | User getCurrentUserDetails() throws ServerException; | ||
240 | 45 | |||
241 | 44 | // DevTeams | 46 | // DevTeams |
242 | 45 | 47 | ||
243 | 46 | DevTeam addNewDevTeam(DevTeam devTeam) throws DevTeamExists, UserPrivilegeException; | 48 | DevTeam addNewDevTeam(DevTeam devTeam) throws DevTeamExists, UserPrivilegeException; |
244 | 47 | 49 | ||
245 | === modified file 'src/au/edu/unimelb/csse/mugle/client/platform/AdminServiceAsync.java' | |||
246 | --- src/au/edu/unimelb/csse/mugle/client/platform/AdminServiceAsync.java 2011-03-20 11:06:48 +0000 | |||
247 | +++ src/au/edu/unimelb/csse/mugle/client/platform/AdminServiceAsync.java 2011-04-29 07:02:27 +0000 | |||
248 | @@ -100,5 +100,7 @@ | |||
249 | 100 | 100 | ||
250 | 101 | void demoteGame(String promotedGameKey, | 101 | void demoteGame(String promotedGameKey, |
251 | 102 | AsyncCallback<GameVersion> callback); | 102 | AsyncCallback<GameVersion> callback); |
252 | 103 | |||
253 | 104 | void getCurrentUserDetails(AsyncCallback<User> callback); | ||
254 | 103 | 105 | ||
255 | 104 | } | 106 | } |
256 | 105 | 107 | ||
257 | === modified file 'src/au/edu/unimelb/csse/mugle/client/platform/DeveloperService.java' | |||
258 | --- src/au/edu/unimelb/csse/mugle/client/platform/DeveloperService.java 2011-03-20 11:06:48 +0000 | |||
259 | +++ src/au/edu/unimelb/csse/mugle/client/platform/DeveloperService.java 2011-04-29 07:02:27 +0000 | |||
260 | @@ -21,12 +21,13 @@ | |||
261 | 21 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameNotExists; | 21 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameNotExists; |
262 | 22 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameVersionExists; | 22 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameVersionExists; |
263 | 23 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameVersionNotExists; | 23 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameVersionNotExists; |
264 | 24 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.ServerException; | ||
265 | 24 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.UserPrivilegeException; | 25 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.UserPrivilegeException; |
266 | 25 | 26 | ||
267 | 26 | import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; | 27 | import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; |
268 | 27 | 28 | ||
269 | 28 | @RemoteServiceRelativePath("dev") | 29 | @RemoteServiceRelativePath("dev") |
271 | 29 | public interface DeveloperService extends UserService { | 30 | public interface DeveloperService extends GuestService { |
272 | 30 | 31 | ||
273 | 31 | GameVersion addGameVersion(GameVersion gameVersion) throws GameVersionExists, GameNotExists, UserPrivilegeException; | 32 | GameVersion addGameVersion(GameVersion gameVersion) throws GameVersionExists, GameNotExists, UserPrivilegeException; |
274 | 32 | 33 | ||
275 | @@ -38,4 +39,5 @@ | |||
276 | 38 | 39 | ||
277 | 39 | boolean removeGameVersion(Long pKey) throws GameVersionNotExists, UserPrivilegeException; | 40 | boolean removeGameVersion(Long pKey) throws GameVersionNotExists, UserPrivilegeException; |
278 | 40 | 41 | ||
279 | 42 | User getCurrentUserDetails() throws ServerException; | ||
280 | 41 | } | 43 | } |
281 | 42 | 44 | ||
282 | === modified file 'src/au/edu/unimelb/csse/mugle/client/platform/DeveloperServiceAsync.java' | |||
283 | --- src/au/edu/unimelb/csse/mugle/client/platform/DeveloperServiceAsync.java 2011-03-20 11:06:48 +0000 | |||
284 | +++ src/au/edu/unimelb/csse/mugle/client/platform/DeveloperServiceAsync.java 2011-04-29 07:02:27 +0000 | |||
285 | @@ -42,4 +42,6 @@ | |||
286 | 42 | 42 | ||
287 | 43 | void removeGameVersion(Long pKey, AsyncCallback<Boolean> callback); | 43 | void removeGameVersion(Long pKey, AsyncCallback<Boolean> callback); |
288 | 44 | 44 | ||
289 | 45 | void getCurrentUserDetails(AsyncCallback<User> callback); | ||
290 | 46 | |||
291 | 45 | } | 47 | } |
292 | 46 | 48 | ||
293 | === renamed file 'src/au/edu/unimelb/csse/mugle/client/platform/UserService.java' => 'src/au/edu/unimelb/csse/mugle/client/platform/GuestService.java' | |||
294 | --- src/au/edu/unimelb/csse/mugle/client/platform/UserService.java 2011-03-09 08:55:08 +0000 | |||
295 | +++ src/au/edu/unimelb/csse/mugle/client/platform/GuestService.java 2011-04-29 07:02:27 +0000 | |||
296 | @@ -17,10 +17,15 @@ | |||
297 | 17 | 17 | ||
298 | 18 | package au.edu.unimelb.csse.mugle.client.platform; | 18 | package au.edu.unimelb.csse.mugle.client.platform; |
299 | 19 | 19 | ||
300 | 20 | import au.edu.unimelb.csse.mugle.shared.model.User; | ||
301 | 21 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.ServerException; | ||
302 | 22 | |||
303 | 20 | import com.google.gwt.user.client.rpc.RemoteService; | 23 | import com.google.gwt.user.client.rpc.RemoteService; |
304 | 21 | import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; | 24 | import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; |
305 | 22 | 25 | ||
308 | 23 | @RemoteServiceRelativePath("users") | 26 | @RemoteServiceRelativePath("guests") |
309 | 24 | public interface UserService extends RemoteService { | 27 | public interface GuestService extends RemoteService { |
310 | 25 | 28 | ||
311 | 29 | User getCurrentUserDetails() throws ServerException; | ||
312 | 30 | |||
313 | 26 | } | 31 | } |
314 | 27 | 32 | ||
315 | === renamed file 'src/au/edu/unimelb/csse/mugle/client/platform/UserServiceAsync.java' => 'src/au/edu/unimelb/csse/mugle/client/platform/GuestServiceAsync.java' | |||
316 | --- src/au/edu/unimelb/csse/mugle/client/platform/UserServiceAsync.java 2011-03-10 04:50:07 +0000 | |||
317 | +++ src/au/edu/unimelb/csse/mugle/client/platform/GuestServiceAsync.java 2011-04-29 07:02:27 +0000 | |||
318 | @@ -19,10 +19,13 @@ | |||
319 | 19 | 19 | ||
320 | 20 | import com.google.gwt.user.client.rpc.AsyncCallback; | 20 | import com.google.gwt.user.client.rpc.AsyncCallback; |
321 | 21 | 21 | ||
322 | 22 | import au.edu.unimelb.csse.mugle.shared.model.User; | ||
323 | 23 | |||
324 | 22 | /** | 24 | /** |
326 | 23 | * The async counterpart of <code>UserService</code>. | 25 | * The async counterpart of <code>GuestService</code>. |
327 | 24 | */ | 26 | */ |
329 | 25 | public interface UserServiceAsync { | 27 | public interface GuestServiceAsync { |
330 | 26 | 28 | ||
331 | 29 | void getCurrentUserDetails(AsyncCallback<User> callback); | ||
332 | 27 | 30 | ||
333 | 28 | } | 31 | } |
334 | 29 | 32 | ||
335 | === added file 'src/au/edu/unimelb/csse/mugle/client/ui/MugleDialogBox.java' | |||
336 | --- src/au/edu/unimelb/csse/mugle/client/ui/MugleDialogBox.java 1970-01-01 00:00:00 +0000 | |||
337 | +++ src/au/edu/unimelb/csse/mugle/client/ui/MugleDialogBox.java 2011-04-29 07:02:27 +0000 | |||
338 | @@ -0,0 +1,104 @@ | |||
339 | 1 | package au.edu.unimelb.csse.mugle.client.ui; | ||
340 | 2 | |||
341 | 3 | import com.google.gwt.event.dom.client.ClickEvent; | ||
342 | 4 | import com.google.gwt.event.dom.client.ClickHandler; | ||
343 | 5 | import com.google.gwt.user.client.ui.Button; | ||
344 | 6 | import com.google.gwt.user.client.ui.DialogBox; | ||
345 | 7 | import com.google.gwt.user.client.ui.FocusWidget; | ||
346 | 8 | import com.google.gwt.user.client.ui.HTML; | ||
347 | 9 | import com.google.gwt.user.client.ui.HorizontalPanel; | ||
348 | 10 | import com.google.gwt.user.client.ui.VerticalPanel; | ||
349 | 11 | |||
350 | 12 | public class MugleDialogBox extends DialogBox { | ||
351 | 13 | |||
352 | 14 | private final Button closeButton = new Button("Close"); | ||
353 | 15 | private final HorizontalPanel bodyHolder = new HorizontalPanel(); | ||
354 | 16 | |||
355 | 17 | private FocusWidget returnFocus = null; | ||
356 | 18 | private HTML body = new HTML(); | ||
357 | 19 | |||
358 | 20 | public MugleDialogBox(String text, HTML body, FocusWidget focus) { | ||
359 | 21 | super(false); | ||
360 | 22 | this.returnFocus = focus; | ||
361 | 23 | this.setText(text); | ||
362 | 24 | this.setup(); | ||
363 | 25 | this.setBody(body); | ||
364 | 26 | } | ||
365 | 27 | |||
366 | 28 | public MugleDialogBox(String text) { | ||
367 | 29 | super(false); | ||
368 | 30 | this.setText(text); | ||
369 | 31 | this.setup(); | ||
370 | 32 | } | ||
371 | 33 | |||
372 | 34 | public MugleDialogBox() { | ||
373 | 35 | super(false); | ||
374 | 36 | this.setup(); | ||
375 | 37 | } | ||
376 | 38 | |||
377 | 39 | private void setup() { | ||
378 | 40 | |||
379 | 41 | this.setAnimationEnabled(true); | ||
380 | 42 | |||
381 | 43 | this.closeButton.getElement().setId("closeButton"); | ||
382 | 44 | VerticalPanel dialogVPanel = new VerticalPanel(); | ||
383 | 45 | dialogVPanel.addStyleName("dialogVPanel"); | ||
384 | 46 | dialogVPanel.add(bodyHolder); | ||
385 | 47 | dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT); | ||
386 | 48 | dialogVPanel.add(closeButton); | ||
387 | 49 | this.setWidget(dialogVPanel); | ||
388 | 50 | |||
389 | 51 | // Add a handler to close the DialogBox | ||
390 | 52 | closeButton.addClickHandler(new DialogClickHandler(this)); | ||
391 | 53 | |||
392 | 54 | } | ||
393 | 55 | |||
394 | 56 | public void show() { | ||
395 | 57 | this.center(); | ||
396 | 58 | this.closeButton.setFocus(true); | ||
397 | 59 | } | ||
398 | 60 | |||
399 | 61 | protected Button getCloseButton() { | ||
400 | 62 | return this.closeButton; | ||
401 | 63 | } | ||
402 | 64 | |||
403 | 65 | protected FocusWidget getReturnFocus() { | ||
404 | 66 | return this.returnFocus; | ||
405 | 67 | } | ||
406 | 68 | |||
407 | 69 | public HTML getBody() { | ||
408 | 70 | return this.body; | ||
409 | 71 | } | ||
410 | 72 | |||
411 | 73 | public void setBody(HTML body) { | ||
412 | 74 | this.body = body; | ||
413 | 75 | if (body != null) { | ||
414 | 76 | this.bodyHolder.clear(); | ||
415 | 77 | this.bodyHolder.add(body); | ||
416 | 78 | } | ||
417 | 79 | } | ||
418 | 80 | |||
419 | 81 | public void setReturnFocus(FocusWidget returnFocus) { | ||
420 | 82 | this.returnFocus = returnFocus; | ||
421 | 83 | } | ||
422 | 84 | |||
423 | 85 | private class DialogClickHandler implements ClickHandler { | ||
424 | 86 | |||
425 | 87 | MugleDialogBox mdb = null; | ||
426 | 88 | |||
427 | 89 | public DialogClickHandler(MugleDialogBox mdb) { | ||
428 | 90 | this.mdb = mdb; | ||
429 | 91 | } | ||
430 | 92 | |||
431 | 93 | @Override | ||
432 | 94 | public void onClick(ClickEvent event) { | ||
433 | 95 | this.mdb.hide(); | ||
434 | 96 | if (this.mdb.getReturnFocus() != null) { | ||
435 | 97 | this.mdb.getReturnFocus().setEnabled(true); | ||
436 | 98 | this.mdb.getReturnFocus().setFocus(true); | ||
437 | 99 | } | ||
438 | 100 | } | ||
439 | 101 | |||
440 | 102 | } | ||
441 | 103 | |||
442 | 104 | } | ||
443 | 0 | 105 | ||
444 | === modified file 'src/au/edu/unimelb/csse/mugle/client/ui/MugleUiBuilder.java' | |||
445 | --- src/au/edu/unimelb/csse/mugle/client/ui/MugleUiBuilder.java 2011-04-29 07:02:27 +0000 | |||
446 | +++ src/au/edu/unimelb/csse/mugle/client/ui/MugleUiBuilder.java 2011-04-29 07:02:27 +0000 | |||
447 | @@ -3,17 +3,38 @@ | |||
448 | 3 | import java.util.Collection; | 3 | import java.util.Collection; |
449 | 4 | import java.util.Iterator; | 4 | import java.util.Iterator; |
450 | 5 | 5 | ||
451 | 6 | import au.edu.unimelb.csse.mugle.client.AuthenticatedUser; | ||
452 | 7 | import au.edu.unimelb.csse.mugle.client.platform.GuestService; | ||
453 | 8 | import au.edu.unimelb.csse.mugle.client.platform.GuestServiceAsync; | ||
454 | 9 | import au.edu.unimelb.csse.mugle.shared.model.Role; | ||
455 | 10 | import au.edu.unimelb.csse.mugle.shared.model.User; | ||
456 | 11 | |||
457 | 12 | import com.google.gwt.core.client.GWT; | ||
458 | 13 | import com.google.gwt.dom.client.Style; | ||
459 | 14 | import com.google.gwt.dom.client.Style.Overflow; | ||
460 | 15 | import com.google.gwt.dom.client.Style.Unit; | ||
461 | 6 | import com.google.gwt.event.dom.client.ClickHandler; | 16 | import com.google.gwt.event.dom.client.ClickHandler; |
462 | 17 | import com.google.gwt.user.client.DOM; | ||
463 | 18 | import com.google.gwt.user.client.rpc.AsyncCallback; | ||
464 | 19 | import com.google.gwt.user.client.ui.AbsolutePanel; | ||
465 | 20 | import com.google.gwt.user.client.ui.Anchor; | ||
466 | 7 | import com.google.gwt.user.client.ui.Button; | 21 | import com.google.gwt.user.client.ui.Button; |
467 | 8 | import com.google.gwt.user.client.ui.CellPanel; | 22 | import com.google.gwt.user.client.ui.CellPanel; |
468 | 23 | import com.google.gwt.user.client.ui.DockLayoutPanel; | ||
469 | 9 | import com.google.gwt.user.client.ui.FlexTable; | 24 | import com.google.gwt.user.client.ui.FlexTable; |
470 | 25 | import com.google.gwt.user.client.ui.Grid; | ||
471 | 26 | import com.google.gwt.user.client.ui.HTML; | ||
472 | 10 | import com.google.gwt.user.client.ui.HorizontalPanel; | 27 | import com.google.gwt.user.client.ui.HorizontalPanel; |
473 | 11 | import com.google.gwt.user.client.ui.Label; | 28 | import com.google.gwt.user.client.ui.Label; |
474 | 29 | import com.google.gwt.user.client.ui.RootPanel; | ||
475 | 30 | import com.google.gwt.user.client.ui.StackPanel; | ||
476 | 12 | import com.google.gwt.user.client.ui.VerticalPanel; | 31 | import com.google.gwt.user.client.ui.VerticalPanel; |
477 | 13 | import com.google.gwt.user.client.ui.Widget; | 32 | import com.google.gwt.user.client.ui.Widget; |
478 | 14 | 33 | ||
479 | 15 | public class MugleUiBuilder { | 34 | public class MugleUiBuilder { |
480 | 16 | 35 | ||
481 | 36 | private static GuestServiceAsync guestService = GWT.create(GuestService.class); | ||
482 | 37 | |||
483 | 17 | private MugleUiBuilder() { } | 38 | private MugleUiBuilder() { } |
484 | 18 | 39 | ||
485 | 19 | public static CellPanel buildStringTable(Collection<Collection<String>> list, Collection<String> headers) { | 40 | public static CellPanel buildStringTable(Collection<Collection<String>> list, Collection<String> headers) { |
486 | @@ -140,5 +161,176 @@ | |||
487 | 140 | if (handler != null) { b.addClickHandler(handler); } | 161 | if (handler != null) { b.addClickHandler(handler); } |
488 | 141 | panel.add(b); | 162 | panel.add(b); |
489 | 142 | } | 163 | } |
490 | 164 | |||
491 | 165 | public static <T extends Widget> T setId(T w, String id) { | ||
492 | 166 | w.getElement().setId(id); | ||
493 | 167 | return w; | ||
494 | 168 | } | ||
495 | 169 | |||
496 | 170 | public static void arrangeUserPanel(Grid userPanel, AuthenticatedUser authuser) { | ||
497 | 171 | |||
498 | 172 | DOM.getElementById("user-panel-title").appendChild((new HTML("<b>MUGLE</b>")).getElement()); | ||
499 | 173 | userPanel.setWidget(0, 0, new HTML("<b>" + authuser.getLoginInfo().getEmailAddress() + "</b>")); | ||
500 | 174 | userPanel.setWidget(0, 1, new HTML("|")); | ||
501 | 175 | userPanel.setWidget(0, 2, authuser.getSignOutLink()); | ||
502 | 176 | |||
503 | 177 | } | ||
504 | 178 | |||
505 | 179 | public static void arrangeMainPanel(RootPanel mainPanel) { | ||
506 | 180 | |||
507 | 181 | AbsolutePanel container = setId(new AbsolutePanel(), "main-panel-container"); | ||
508 | 182 | mainPanel.add(container); | ||
509 | 183 | |||
510 | 184 | AbsolutePanel inner = setId(new AbsolutePanel(), "main-panel-container-inner"); | ||
511 | 185 | inner.getElement().getStyle().setOverflow(Overflow.VISIBLE); | ||
512 | 186 | container.add(inner); | ||
513 | 187 | |||
514 | 188 | AbsolutePanel tp = setId(new AbsolutePanel(), "tools-panel"); | ||
515 | 189 | AbsolutePanel rp = setId(new AbsolutePanel(), "right-panel"); | ||
516 | 190 | AbsolutePanel rpi = setId(new AbsolutePanel(), "right-panel-inner"); | ||
517 | 191 | |||
518 | 192 | tp.add(buildToolsPanel()); | ||
519 | 193 | rpi.add(buildRightPanel()); | ||
520 | 194 | rp.add(rpi); | ||
521 | 195 | |||
522 | 196 | inner.add(tp); | ||
523 | 197 | inner.add(rp); | ||
524 | 198 | |||
525 | 199 | } | ||
526 | 200 | |||
527 | 201 | private static Widget buildToolsPanel() { | ||
528 | 202 | |||
529 | 203 | // left panel | ||
530 | 204 | final StackPanel sp = new StackPanel(); | ||
531 | 205 | sp.setWidth("100%"); | ||
532 | 206 | sp.getElement().getStyle().setFontSize(1, Unit.EM); | ||
533 | 207 | |||
534 | 208 | System.out.println("test1"); | ||
535 | 209 | |||
536 | 210 | guestService.getCurrentUserDetails(new AsyncCallback<User>() { | ||
537 | 211 | |||
538 | 212 | @Override | ||
539 | 213 | public void onSuccess(User result) { | ||
540 | 214 | |||
541 | 215 | System.out.println("success"); | ||
542 | 216 | |||
543 | 217 | Widget tmp = null; | ||
544 | 218 | if ((tmp = buildMyMugle(result)) != null) { | ||
545 | 219 | sp.add(tmp, "My Mugle", false); | ||
546 | 220 | } | ||
547 | 221 | if ((tmp = buildMuglePublic(result)) != null) { | ||
548 | 222 | sp.add(tmp, "Mugle Public", false); | ||
549 | 223 | } | ||
550 | 224 | if ((tmp = buildSettings(result)) != null) { | ||
551 | 225 | sp.add(tmp, "Settings", false); | ||
552 | 226 | } | ||
553 | 227 | if ((tmp = buildAdmin(result)) != null) { | ||
554 | 228 | sp.add(tmp, "Admin", false); | ||
555 | 229 | } | ||
556 | 230 | |||
557 | 231 | } | ||
558 | 232 | |||
559 | 233 | @Override | ||
560 | 234 | public void onFailure(Throwable caught) { | ||
561 | 235 | |||
562 | 236 | // TODO Auto-generated method stub | ||
563 | 237 | System.out.println("fail"); | ||
564 | 238 | |||
565 | 239 | } | ||
566 | 240 | |||
567 | 241 | }); | ||
568 | 242 | |||
569 | 243 | return sp; | ||
570 | 244 | |||
571 | 245 | } | ||
572 | 246 | |||
573 | 247 | private static Widget buildMyMugle(User user) { | ||
574 | 248 | |||
575 | 249 | Role role = user.getRole(); | ||
576 | 250 | |||
577 | 251 | switch (role) { | ||
578 | 252 | |||
579 | 253 | case ADMIN: | ||
580 | 254 | case DEVELOPER: | ||
581 | 255 | |||
582 | 256 | VerticalPanel vp = new VerticalPanel(); | ||
583 | 257 | vp.add(new Anchor("Promoted Games")); | ||
584 | 258 | vp.add(new Anchor("Games Gallery")); | ||
585 | 259 | vp.add(new Anchor("Promoted Games")); | ||
586 | 260 | return vp; | ||
587 | 261 | |||
588 | 262 | } | ||
589 | 263 | |||
590 | 264 | return null; | ||
591 | 265 | |||
592 | 266 | } | ||
593 | 143 | 267 | ||
594 | 268 | private static Widget buildMuglePublic(User user) { | ||
595 | 269 | |||
596 | 270 | VerticalPanel vp = new VerticalPanel(); | ||
597 | 271 | |||
598 | 272 | vp.add(new Anchor("Promoted Games")); | ||
599 | 273 | vp.add(new Anchor("Games Gallery")); | ||
600 | 274 | |||
601 | 275 | return vp; | ||
602 | 276 | |||
603 | 277 | } | ||
604 | 278 | |||
605 | 279 | private static Widget buildSettings(User user) { | ||
606 | 280 | |||
607 | 281 | VerticalPanel vp = new VerticalPanel(); | ||
608 | 282 | |||
609 | 283 | vp.add(new Anchor("Settings 1")); | ||
610 | 284 | vp.add(new Anchor("Settings 2")); | ||
611 | 285 | |||
612 | 286 | return vp; | ||
613 | 287 | |||
614 | 288 | } | ||
615 | 289 | |||
616 | 290 | private static Widget buildAdmin(User user) { | ||
617 | 291 | |||
618 | 292 | Role role = user.getRole(); | ||
619 | 293 | |||
620 | 294 | switch (role) { | ||
621 | 295 | |||
622 | 296 | case ADMIN: | ||
623 | 297 | |||
624 | 298 | VerticalPanel vp = new VerticalPanel(); | ||
625 | 299 | vp.add(new Anchor("Promoted Games")); | ||
626 | 300 | vp.add(new Anchor("Games Gallery")); | ||
627 | 301 | vp.add(new Anchor("Promoted Games")); | ||
628 | 302 | return vp; | ||
629 | 303 | |||
630 | 304 | } | ||
631 | 305 | |||
632 | 306 | return null; | ||
633 | 307 | |||
634 | 308 | } | ||
635 | 309 | |||
636 | 310 | private static Widget buildRightPanel() { | ||
637 | 311 | |||
638 | 312 | final HorizontalPanel panel = new HorizontalPanel(); | ||
639 | 313 | |||
640 | 314 | panel.add(new HTML("Under Construction!")); | ||
641 | 315 | |||
642 | 316 | // debug | ||
643 | 317 | GuestServiceAsync us = GWT.create(GuestService.class); | ||
644 | 318 | us.getCurrentUserDetails(new AsyncCallback<User>() { | ||
645 | 319 | |||
646 | 320 | @Override | ||
647 | 321 | public void onSuccess(User result) { | ||
648 | 322 | panel.add(new HTML("NAME: "+result.getFullName())); | ||
649 | 323 | } | ||
650 | 324 | |||
651 | 325 | @Override | ||
652 | 326 | public void onFailure(Throwable caught) { | ||
653 | 327 | panel.add(new HTML("FAILED!")); | ||
654 | 328 | } | ||
655 | 329 | |||
656 | 330 | }); | ||
657 | 331 | |||
658 | 332 | return panel; | ||
659 | 333 | |||
660 | 334 | } | ||
661 | 335 | |||
662 | 144 | } | 336 | } |
663 | 145 | 337 | ||
664 | === renamed file 'src/au/edu/unimelb/csse/mugle/server/LoginServiceImpl.java' => 'src/au/edu/unimelb/csse/mugle/server/ClientServiceImpl.java' | |||
665 | --- src/au/edu/unimelb/csse/mugle/server/LoginServiceImpl.java 2011-04-29 07:02:27 +0000 | |||
666 | +++ src/au/edu/unimelb/csse/mugle/server/ClientServiceImpl.java 2011-04-29 07:02:27 +0000 | |||
667 | @@ -20,12 +20,11 @@ | |||
668 | 20 | import com.google.appengine.api.users.UserService; | 20 | import com.google.appengine.api.users.UserService; |
669 | 21 | import com.google.appengine.api.users.UserServiceFactory; | 21 | import com.google.appengine.api.users.UserServiceFactory; |
670 | 22 | import au.edu.unimelb.csse.mugle.client.LoginInfo; | 22 | import au.edu.unimelb.csse.mugle.client.LoginInfo; |
672 | 23 | import au.edu.unimelb.csse.mugle.client.LoginService; | 23 | import au.edu.unimelb.csse.mugle.client.ClientService; |
673 | 24 | import com.google.gwt.user.server.rpc.RemoteServiceServlet; | 24 | import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
674 | 25 | 25 | ||
675 | 26 | @SuppressWarnings("serial") | 26 | @SuppressWarnings("serial") |
678 | 27 | public class LoginServiceImpl extends RemoteServiceServlet implements | 27 | public class ClientServiceImpl extends RemoteServiceServlet implements ClientService { |
677 | 28 | LoginService { | ||
679 | 29 | 28 | ||
680 | 30 | public LoginInfo login(String requestUri) { | 29 | public LoginInfo login(String requestUri) { |
681 | 31 | UserService userService = UserServiceFactory.getUserService(); | 30 | UserService userService = UserServiceFactory.getUserService(); |
682 | 32 | 31 | ||
683 | === modified file 'src/au/edu/unimelb/csse/mugle/server/DataTestServiceImpl.java' | |||
684 | --- src/au/edu/unimelb/csse/mugle/server/DataTestServiceImpl.java 2011-04-29 07:02:27 +0000 | |||
685 | +++ src/au/edu/unimelb/csse/mugle/server/DataTestServiceImpl.java 2011-04-29 07:02:27 +0000 | |||
686 | @@ -31,26 +31,35 @@ | |||
687 | 31 | 31 | ||
688 | 32 | PersistenceManager pm = PMF.getManager(); | 32 | PersistenceManager pm = PMF.getManager(); |
689 | 33 | 33 | ||
690 | 34 | System.err.println("test1"); | ||
691 | 35 | |||
692 | 34 | if (pm == null) { | 36 | if (pm == null) { |
693 | 35 | return "Datastore populating failed!"; | 37 | return "Datastore populating failed!"; |
694 | 36 | } | 38 | } |
695 | 37 | 39 | ||
696 | 40 | System.err.println("test2"); | ||
697 | 41 | |||
698 | 38 | UserData[] users = new UserData[] { | 42 | UserData[] users = new UserData[] { |
699 | 39 | new UserData("~matt", "Matt Giuca", "matt@test.com", Role.ADMIN), | 43 | new UserData("~matt", "Matt Giuca", "matt@test.com", Role.ADMIN), |
700 | 40 | new UserData("~scott", "Scott Ritchie", "scott@test.com", Role.ADMIN), | 44 | new UserData("~scott", "Scott Ritchie", "scott@test.com", Role.ADMIN), |
701 | 41 | new UserData("~prageeth", "Prageeth Silva", "prageeth@test.com", Role.ADMIN), | 45 | new UserData("~prageeth", "Prageeth Silva", "prageeth@test.com", Role.ADMIN), |
702 | 42 | new UserData("~bob", "Bob", "bob@test.com", Role.DEVELOPER), | 46 | new UserData("~bob", "Bob", "bob@test.com", Role.DEVELOPER), |
703 | 43 | new UserData("~jim", "Jim", "jim@test.com", Role.DEVELOPER), | 47 | new UserData("~jim", "Jim", "jim@test.com", Role.DEVELOPER), |
705 | 44 | new UserData("~john", "John", "john@test.com", Role.USER), | 48 | new UserData("~john", "John", "john@test.com", Role.GUEST), |
706 | 45 | new UserData("~admin", "Admin", "admin@test.com", Role.ADMIN), | 49 | new UserData("~admin", "Admin", "admin@test.com", Role.ADMIN), |
708 | 46 | new UserData("~dev", "Dev", "dev@test.com", Role.DEVELOPER) | 50 | new UserData("~dev", "Dev", "dev@test.com", Role.DEVELOPER), |
709 | 51 | new UserData("~test", "Test", "test@example.com", Role.DEVELOPER) | ||
710 | 47 | }; | 52 | }; |
711 | 48 | 53 | ||
712 | 54 | System.err.println("test3"); | ||
713 | 55 | |||
714 | 49 | pm.makePersistentAll(users); | 56 | pm.makePersistentAll(users); |
715 | 50 | pm.makePersistent(users[0]); | 57 | pm.makePersistent(users[0]); |
716 | 51 | pm.flush(); | 58 | pm.flush(); |
717 | 52 | pm.close(); | 59 | pm.close(); |
718 | 53 | 60 | ||
719 | 61 | System.err.println("test4"); | ||
720 | 62 | |||
721 | 54 | return "Data addition succeful!"; | 63 | return "Data addition succeful!"; |
722 | 55 | 64 | ||
723 | 56 | } | 65 | } |
724 | 57 | 66 | ||
725 | === added file 'src/au/edu/unimelb/csse/mugle/server/GameFileServer.java' | |||
726 | --- src/au/edu/unimelb/csse/mugle/server/GameFileServer.java 1970-01-01 00:00:00 +0000 | |||
727 | +++ src/au/edu/unimelb/csse/mugle/server/GameFileServer.java 2011-04-29 07:02:27 +0000 | |||
728 | @@ -0,0 +1,94 @@ | |||
729 | 1 | /* Melbourne University Game-based Learning Environment | ||
730 | 2 | * Copyright (C) 2011 The University of Melbourne | ||
731 | 3 | * | ||
732 | 4 | * This program is free software: you can redistribute it and/or modify | ||
733 | 5 | * it under the terms of the GNU General Public License as published by | ||
734 | 6 | * the Free Software Foundation, either version 3 of the License, or | ||
735 | 7 | * (at your option) any later version. | ||
736 | 8 | * | ||
737 | 9 | * This program is distributed in the hope that it will be useful, | ||
738 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
739 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
740 | 12 | * GNU General Public License for more details. | ||
741 | 13 | * | ||
742 | 14 | * You should have received a copy of the GNU General Public License | ||
743 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
744 | 16 | */ | ||
745 | 17 | package au.edu.unimelb.csse.mugle.server; | ||
746 | 18 | |||
747 | 19 | import java.io.IOException; | ||
748 | 20 | import java.util.Map; | ||
749 | 21 | import java.util.Map.Entry; | ||
750 | 22 | |||
751 | 23 | import javax.servlet.ServletException; | ||
752 | 24 | import javax.servlet.http.HttpServlet; | ||
753 | 25 | import javax.servlet.http.HttpServletRequest; | ||
754 | 26 | import javax.servlet.http.HttpServletResponse; | ||
755 | 27 | |||
756 | 28 | import au.edu.unimelb.csse.mugle.server.model.GameFileData; | ||
757 | 29 | import au.edu.unimelb.csse.mugle.server.model.GameFileGetter; | ||
758 | 30 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameFileNotExists; | ||
759 | 31 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameNotExists; | ||
760 | 32 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameVersionNotExists; | ||
761 | 33 | |||
762 | 34 | import com.google.appengine.api.blobstore.BlobKey; | ||
763 | 35 | import com.google.appengine.api.blobstore.BlobstoreService; | ||
764 | 36 | import com.google.appengine.api.blobstore.BlobstoreServiceFactory; | ||
765 | 37 | |||
766 | 38 | @SuppressWarnings("serial") | ||
767 | 39 | public class GameFileServer extends HttpServlet { | ||
768 | 40 | |||
769 | 41 | public void doGet(HttpServletRequest req, HttpServletResponse res) | ||
770 | 42 | throws IOException { | ||
771 | 43 | BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService(); | ||
772 | 44 | |||
773 | 45 | try { | ||
774 | 46 | BlobKey blobKey = getBlobKey(req); | ||
775 | 47 | blobstoreService.serve(blobKey, res); | ||
776 | 48 | } catch (GameFileNotExists e) { | ||
777 | 49 | //TODO: Construct a page with the error | ||
778 | 50 | } | ||
779 | 51 | } | ||
780 | 52 | |||
781 | 53 | private BlobKey getBlobKey(HttpServletRequest req) | ||
782 | 54 | throws GameFileNotExists { | ||
783 | 55 | GameFileGetter gfg = new GameFileGetter(); | ||
784 | 56 | String gameName = null; | ||
785 | 57 | String gameVersion = null; | ||
786 | 58 | String path = null; | ||
787 | 59 | |||
788 | 60 | /* We need to parse the request to get the gameName, gameVersion | ||
789 | 61 | * and path, | ||
790 | 62 | * URLs are in the form /game/gameName/gameVersion/path | ||
791 | 63 | */ | ||
792 | 64 | String toParse = req.getRequestURI().split("/game/")[1]; // gets everything after /game/ in the URI | ||
793 | 65 | String[] splitted = toParse.split("/"); | ||
794 | 66 | gameName = splitted[0]; | ||
795 | 67 | gameVersion = splitted[1]; | ||
796 | 68 | path = toParse.split(gameVersion)[1]; | ||
797 | 69 | |||
798 | 70 | try { | ||
799 | 71 | GameFileData file = gfg.getGameFile(gameName, gameVersion, path); | ||
800 | 72 | return file.getBlobKey(); | ||
801 | 73 | } catch (GameNotExists e) { | ||
802 | 74 | throw new GameFileNotExists(gameName, gameVersion, path); | ||
803 | 75 | } catch (GameVersionNotExists e) { | ||
804 | 76 | throw new GameFileNotExists(gameName, gameVersion, path); | ||
805 | 77 | } | ||
806 | 78 | } | ||
807 | 79 | |||
808 | 80 | /* | ||
809 | 81 | public void doPost(HttpServletRequest req, HttpServletResponse res) | ||
810 | 82 | throws ServletException, IOException{ | ||
811 | 83 | BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService(); | ||
812 | 84 | |||
813 | 85 | Map<String, BlobKey> blobs = blobstoreService.getUploadedBlobs(req); | ||
814 | 86 | /* We want to iterate over each of the blobs, and create the | ||
815 | 87 | * appropriate datastore classes | ||
816 | 88 | * | ||
817 | 89 | for(Entry<String, BlobKey> blobEntry : blobs.entrySet()){ | ||
818 | 90 | |||
819 | 91 | } | ||
820 | 92 | |||
821 | 93 | } */ | ||
822 | 94 | } | ||
823 | 0 | 95 | ||
824 | === modified file 'src/au/edu/unimelb/csse/mugle/server/api/BadgeServiceImpl.java' | |||
825 | --- src/au/edu/unimelb/csse/mugle/server/api/BadgeServiceImpl.java 2011-04-29 07:02:27 +0000 | |||
826 | +++ src/au/edu/unimelb/csse/mugle/server/api/BadgeServiceImpl.java 2011-04-29 07:02:27 +0000 | |||
827 | @@ -58,8 +58,6 @@ | |||
828 | 58 | UserAchievementGetter u = new UserAchievementGetter(); | 58 | UserAchievementGetter u = new UserAchievementGetter(); |
829 | 59 | try { | 59 | try { |
830 | 60 | return u.getUserAchievement(pm, name, gameToken); | 60 | return u.getUserAchievement(pm, name, gameToken); |
831 | 61 | } catch (UserNotExists e) { | ||
832 | 62 | throw new Error(e); | ||
833 | 63 | } catch (AchievementNotExists e) { | 61 | } catch (AchievementNotExists e) { |
834 | 64 | throw new BadgeError(e.getMessage()); | 62 | throw new BadgeError(e.getMessage()); |
835 | 65 | } | 63 | } |
836 | 66 | 64 | ||
837 | === modified file 'src/au/edu/unimelb/csse/mugle/server/api/HighscoreServiceImpl.java' | |||
838 | --- src/au/edu/unimelb/csse/mugle/server/api/HighscoreServiceImpl.java 2011-04-29 07:02:27 +0000 | |||
839 | +++ src/au/edu/unimelb/csse/mugle/server/api/HighscoreServiceImpl.java 2011-04-29 07:02:27 +0000 | |||
840 | @@ -22,8 +22,6 @@ | |||
841 | 22 | import au.edu.unimelb.csse.mugle.server.model.UserGameProfileGetter; | 22 | import au.edu.unimelb.csse.mugle.server.model.UserGameProfileGetter; |
842 | 23 | import au.edu.unimelb.csse.mugle.shared.api.GameTokenError; | 23 | import au.edu.unimelb.csse.mugle.shared.api.GameTokenError; |
843 | 24 | import au.edu.unimelb.csse.mugle.server.model.UserGameProfileData; | 24 | import au.edu.unimelb.csse.mugle.server.model.UserGameProfileData; |
844 | 25 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.UserNotExists; | ||
845 | 26 | |||
846 | 27 | import com.google.gwt.user.server.rpc.RemoteServiceServlet; | 25 | import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
847 | 28 | 26 | ||
848 | 29 | import javax.jdo.PersistenceManager; | 27 | import javax.jdo.PersistenceManager; |
849 | @@ -40,11 +38,7 @@ | |||
850 | 40 | public int getHighScore(String gameToken) throws GameTokenError { | 38 | public int getHighScore(String gameToken) throws GameTokenError { |
851 | 41 | UserGameProfileGetter u = new UserGameProfileGetter(); | 39 | UserGameProfileGetter u = new UserGameProfileGetter(); |
852 | 42 | UserGameProfileData ugp; | 40 | UserGameProfileData ugp; |
858 | 43 | try { | 41 | ugp = u.getCurrentUserGameProfile(gameToken); |
854 | 44 | ugp = u.getCurrentUserGameProfile(gameToken); | ||
855 | 45 | } catch (UserNotExists e) { | ||
856 | 46 | throw new Error(e); | ||
857 | 47 | } | ||
859 | 48 | return ugp.getHighscore(); | 42 | return ugp.getHighscore(); |
860 | 49 | } | 43 | } |
861 | 50 | 44 | ||
862 | @@ -56,8 +50,6 @@ | |||
863 | 56 | ugp = u.getCurrentUserGameProfile(pm, gameToken); | 50 | ugp = u.getCurrentUserGameProfile(pm, gameToken); |
864 | 57 | if (score > ugp.getHighscore()) | 51 | if (score > ugp.getHighscore()) |
865 | 58 | ugp.setHighscore(score); | 52 | ugp.setHighscore(score); |
866 | 59 | } catch (UserNotExists e) { | ||
867 | 60 | throw new Error(e); | ||
868 | 61 | } finally { | 53 | } finally { |
869 | 62 | pm.close(); | 54 | pm.close(); |
870 | 63 | } | 55 | } |
871 | 64 | 56 | ||
872 | === modified file 'src/au/edu/unimelb/csse/mugle/server/api/KeyValueServiceImpl.java' | |||
873 | --- src/au/edu/unimelb/csse/mugle/server/api/KeyValueServiceImpl.java 2011-04-29 07:02:27 +0000 | |||
874 | +++ src/au/edu/unimelb/csse/mugle/server/api/KeyValueServiceImpl.java 2011-04-29 07:02:27 +0000 | |||
875 | @@ -25,8 +25,6 @@ | |||
876 | 25 | import au.edu.unimelb.csse.mugle.shared.api.GameTokenError; | 25 | import au.edu.unimelb.csse.mugle.shared.api.GameTokenError; |
877 | 26 | import au.edu.unimelb.csse.mugle.shared.api.KeyError; | 26 | import au.edu.unimelb.csse.mugle.shared.api.KeyError; |
878 | 27 | import au.edu.unimelb.csse.mugle.server.model.KeyValuePairData; | 27 | import au.edu.unimelb.csse.mugle.server.model.KeyValuePairData; |
879 | 28 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.*; | ||
880 | 29 | |||
881 | 30 | import com.google.gwt.user.server.rpc.RemoteServiceServlet; | 28 | import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
882 | 31 | 29 | ||
883 | 32 | import javax.jdo.PersistenceManager; | 30 | import javax.jdo.PersistenceManager; |
884 | @@ -48,8 +46,6 @@ | |||
885 | 48 | try { | 46 | try { |
886 | 49 | kvp = k.getKeyValuePair(pm, key, gameToken, true); | 47 | kvp = k.getKeyValuePair(pm, key, gameToken, true); |
887 | 50 | kvp.setValue(value); | 48 | kvp.setValue(value); |
888 | 51 | } catch (UserNotExists e) { | ||
889 | 52 | throw new Error(e); | ||
890 | 53 | } catch (KeyError e) { | 49 | } catch (KeyError e) { |
891 | 54 | // XXX This should never happen (since we are using createIfNotFound=true) | 50 | // XXX This should never happen (since we are using createIfNotFound=true) |
892 | 55 | throw new Error(e); | 51 | throw new Error(e); |
893 | @@ -63,11 +59,7 @@ | |||
894 | 63 | { | 59 | { |
895 | 64 | KeyValuePairGetter k = new KeyValuePairGetter(); | 60 | KeyValuePairGetter k = new KeyValuePairGetter(); |
896 | 65 | KeyValuePairData kvp; | 61 | KeyValuePairData kvp; |
902 | 66 | try { | 62 | kvp = k.getKeyValuePair(key, gameToken); |
898 | 67 | kvp = k.getKeyValuePair(key, gameToken); | ||
899 | 68 | } catch (UserNotExists e) { | ||
900 | 69 | throw new Error(e); | ||
901 | 70 | } | ||
903 | 71 | return (Serializable) kvp.getValue(); | 63 | return (Serializable) kvp.getValue(); |
904 | 72 | } | 64 | } |
905 | 73 | 65 | ||
906 | @@ -77,8 +69,6 @@ | |||
907 | 77 | KeyValuePairGetter k = new KeyValuePairGetter(); | 69 | KeyValuePairGetter k = new KeyValuePairGetter(); |
908 | 78 | try { | 70 | try { |
909 | 79 | k.getKeyValuePair(key, gameToken); | 71 | k.getKeyValuePair(key, gameToken); |
910 | 80 | } catch (UserNotExists e) { | ||
911 | 81 | throw new Error(e); | ||
912 | 82 | } catch (KeyError e) { | 72 | } catch (KeyError e) { |
913 | 83 | return false; | 73 | return false; |
914 | 84 | } | 74 | } |
915 | 85 | 75 | ||
916 | === modified file 'src/au/edu/unimelb/csse/mugle/server/api/UserServiceImpl.java' | |||
917 | --- src/au/edu/unimelb/csse/mugle/server/api/UserServiceImpl.java 2011-04-29 07:02:27 +0000 | |||
918 | +++ src/au/edu/unimelb/csse/mugle/server/api/UserServiceImpl.java 2011-04-29 07:02:27 +0000 | |||
919 | @@ -19,8 +19,6 @@ | |||
920 | 19 | 19 | ||
921 | 20 | import au.edu.unimelb.csse.mugle.client.api.UserService; | 20 | import au.edu.unimelb.csse.mugle.client.api.UserService; |
922 | 21 | import au.edu.unimelb.csse.mugle.server.model.UserGetter; | 21 | import au.edu.unimelb.csse.mugle.server.model.UserGetter; |
923 | 22 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.UserNotExists; | ||
924 | 23 | |||
925 | 24 | import com.google.gwt.user.server.rpc.RemoteServiceServlet; | 22 | import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
926 | 25 | 23 | ||
927 | 26 | 24 | ||
928 | @@ -34,25 +32,11 @@ | |||
929 | 34 | 32 | ||
930 | 35 | public String getUserNickName() { | 33 | public String getUserNickName() { |
931 | 36 | UserGetter u = new UserGetter(); | 34 | UserGetter u = new UserGetter(); |
940 | 37 | try | 35 | return u.getCurrentUser().getUrlName(); |
933 | 38 | { | ||
934 | 39 | return u.getCurrentUser().getUrlName(); | ||
935 | 40 | } | ||
936 | 41 | catch (UserNotExists e) | ||
937 | 42 | { | ||
938 | 43 | throw new Error(e); | ||
939 | 44 | } | ||
941 | 45 | } | 36 | } |
942 | 46 | 37 | ||
943 | 47 | public String getUserID() { | 38 | public String getUserID() { |
944 | 48 | UserGetter u = new UserGetter(); | 39 | UserGetter u = new UserGetter(); |
953 | 49 | try | 40 | return u.getCurrentUser().getGoogleID(); |
946 | 50 | { | ||
947 | 51 | return u.getCurrentUser().getGoogleID(); | ||
948 | 52 | } | ||
949 | 53 | catch (UserNotExists e) | ||
950 | 54 | { | ||
951 | 55 | throw new Error(e); | ||
952 | 56 | } | ||
954 | 57 | } | 41 | } |
955 | 58 | } | 42 | } |
956 | 59 | 43 | ||
957 | === modified file 'src/au/edu/unimelb/csse/mugle/server/model/AchievementGetter.java' | |||
958 | --- src/au/edu/unimelb/csse/mugle/server/model/AchievementGetter.java 2011-04-29 07:02:27 +0000 | |||
959 | +++ src/au/edu/unimelb/csse/mugle/server/model/AchievementGetter.java 2011-04-29 07:02:27 +0000 | |||
960 | @@ -17,6 +17,8 @@ | |||
961 | 17 | 17 | ||
962 | 18 | package au.edu.unimelb.csse.mugle.server.model; | 18 | package au.edu.unimelb.csse.mugle.server.model; |
963 | 19 | 19 | ||
964 | 20 | import java.util.List; | ||
965 | 21 | |||
966 | 20 | import javax.jdo.PersistenceManager; | 22 | import javax.jdo.PersistenceManager; |
967 | 21 | import javax.jdo.Query; | 23 | import javax.jdo.Query; |
968 | 22 | 24 | ||
969 | @@ -54,6 +56,7 @@ | |||
970 | 54 | * @throws GameTokenError | 56 | * @throws GameTokenError |
971 | 55 | * @throws AchievementNotExists | 57 | * @throws AchievementNotExists |
972 | 56 | */ | 58 | */ |
973 | 59 | @SuppressWarnings("unchecked") | ||
974 | 57 | public AchievementData getAchievement(PersistenceManager pm, String name, String gameToken) | 60 | public AchievementData getAchievement(PersistenceManager pm, String name, String gameToken) |
975 | 58 | throws GameTokenError, AchievementNotExists { | 61 | throws GameTokenError, AchievementNotExists { |
976 | 59 | GameGetter g = new GameGetter(); | 62 | GameGetter g = new GameGetter(); |
977 | @@ -61,13 +64,13 @@ | |||
978 | 61 | 64 | ||
979 | 62 | Query q = pm.newQuery(AchievementData.class, "game == g && name == n"); | 65 | Query q = pm.newQuery(AchievementData.class, "game == g && name == n"); |
980 | 63 | q.declareParameters("GameData g, String n"); | 66 | q.declareParameters("GameData g, String n"); |
982 | 64 | AchievementData achievement = (AchievementData) q.execute(curGame, name); | 67 | List<AchievementData> results = (List<AchievementData>) q.execute(curGame, name); |
983 | 65 | 68 | ||
985 | 66 | if (achievement == null) { | 69 | if (results.isEmpty()) { |
986 | 67 | throw new AchievementNotExists(curGame.getUrlName(), name); | 70 | throw new AchievementNotExists(curGame.getUrlName(), name); |
987 | 68 | } | 71 | } |
988 | 69 | 72 | ||
990 | 70 | return achievement; | 73 | return results.get(0); |
991 | 71 | } | 74 | } |
992 | 72 | 75 | ||
993 | 73 | /** | 76 | /** |
994 | 74 | 77 | ||
995 | === modified file 'src/au/edu/unimelb/csse/mugle/server/model/DevTeamGetter.java' | |||
996 | --- src/au/edu/unimelb/csse/mugle/server/model/DevTeamGetter.java 2011-04-29 07:02:27 +0000 | |||
997 | +++ src/au/edu/unimelb/csse/mugle/server/model/DevTeamGetter.java 2011-04-29 07:02:27 +0000 | |||
998 | @@ -1,5 +1,7 @@ | |||
999 | 1 | package au.edu.unimelb.csse.mugle.server.model; | 1 | package au.edu.unimelb.csse.mugle.server.model; |
1000 | 2 | 2 | ||
1001 | 3 | import java.util.List; | ||
1002 | 4 | |||
1003 | 3 | import javax.jdo.PersistenceManager; | 5 | import javax.jdo.PersistenceManager; |
1004 | 4 | import javax.jdo.Query; | 6 | import javax.jdo.Query; |
1005 | 5 | 7 | ||
1006 | @@ -31,17 +33,17 @@ | |||
1007 | 31 | * @return The DevTeamData | 33 | * @return The DevTeamData |
1008 | 32 | * @throws DevTeamDataNotExists | 34 | * @throws DevTeamDataNotExists |
1009 | 33 | */ | 35 | */ |
1010 | 36 | @SuppressWarnings("unchecked") | ||
1011 | 34 | public DevTeamData getDevTeam(PersistenceManager pm, String name) throws DevTeamNotExists { | 37 | public DevTeamData getDevTeam(PersistenceManager pm, String name) throws DevTeamNotExists { |
1012 | 35 | DevTeamData devTeam= null; | ||
1013 | 36 | Query q = pm.newQuery(DevTeamData.class, "urlName == u"); | 38 | Query q = pm.newQuery(DevTeamData.class, "urlName == u"); |
1014 | 37 | q.declareParameters("String u"); | 39 | q.declareParameters("String u"); |
1016 | 38 | devTeam = (DevTeamData) q.execute(name); | 40 | List<DevTeamData> results = (List<DevTeamData>) q.execute(name); |
1017 | 39 | 41 | ||
1019 | 40 | if (devTeam == null) { | 42 | if (results.isEmpty()) { |
1020 | 41 | throw new DevTeamNotExists(name); | 43 | throw new DevTeamNotExists(name); |
1021 | 42 | } | 44 | } |
1022 | 43 | 45 | ||
1024 | 44 | return devTeam; | 46 | return results.get(0); |
1025 | 45 | } | 47 | } |
1026 | 46 | /** | 48 | /** |
1027 | 47 | * Gets the DevTeamDataData by its primary key - READ ONLY | 49 | * Gets the DevTeamDataData by its primary key - READ ONLY |
1028 | 48 | 50 | ||
1029 | === modified file 'src/au/edu/unimelb/csse/mugle/server/model/GameFileData.java' | |||
1030 | --- src/au/edu/unimelb/csse/mugle/server/model/GameFileData.java 2011-04-29 07:02:27 +0000 | |||
1031 | +++ src/au/edu/unimelb/csse/mugle/server/model/GameFileData.java 2011-04-29 07:02:27 +0000 | |||
1032 | @@ -17,9 +17,6 @@ | |||
1033 | 17 | 17 | ||
1034 | 18 | package au.edu.unimelb.csse.mugle.server.model; | 18 | package au.edu.unimelb.csse.mugle.server.model; |
1035 | 19 | 19 | ||
1036 | 20 | import java.util.HashSet; | ||
1037 | 21 | import java.util.Set; | ||
1038 | 22 | |||
1039 | 23 | import javax.jdo.annotations.IdGeneratorStrategy; | 20 | import javax.jdo.annotations.IdGeneratorStrategy; |
1040 | 24 | import javax.jdo.annotations.PersistenceCapable; | 21 | import javax.jdo.annotations.PersistenceCapable; |
1041 | 25 | import javax.jdo.annotations.Persistent; | 22 | import javax.jdo.annotations.Persistent; |
1042 | @@ -54,17 +51,16 @@ | |||
1043 | 54 | 51 | ||
1044 | 55 | @UserLevel(privateView=Role.DEVELOPER, publicView=Role.DEVELOPER, useMethod=true, mappedBy="getBlobKeyString") | 52 | @UserLevel(privateView=Role.DEVELOPER, publicView=Role.DEVELOPER, useMethod=true, mappedBy="getBlobKeyString") |
1045 | 56 | @Persistent | 53 | @Persistent |
1047 | 57 | private BlobKey blobKey; //key to the actual blob | 54 | private BlobKey blobKey; //key to the actual blob -- may be shared between GameFiles across versions |
1048 | 58 | 55 | ||
1051 | 59 | // Many-to-many | 56 | @UserLevel(privateView=Role.DEVELOPER, publicView=Role.DEVELOPER, mappedBy="version") |
1050 | 60 | @UserLevel(privateView=Role.DEVELOPER, publicView=Role.DEVELOPER, useMethod=true, mappedBy="keysToGameVersions") | ||
1052 | 61 | @Persistent | 57 | @Persistent |
1054 | 62 | private Set<Key> versions; //Game versions this file belongs to | 58 | private GameVersionData version; //Game version this Gamefile belongs to |
1055 | 63 | 59 | ||
1056 | 64 | 60 | ||
1057 | 65 | // Constructors | 61 | // Constructors |
1058 | 66 | public GameFileData() { | 62 | public GameFileData() { |
1060 | 67 | this.versions = new HashSet<Key>(); | 63 | this.version = null; |
1061 | 68 | this.setMimeType(null); | 64 | this.setMimeType(null); |
1062 | 69 | this.setBlobKey(null); | 65 | this.setBlobKey(null); |
1063 | 70 | this.path = null; | 66 | this.path = null; |
1064 | @@ -101,8 +97,8 @@ | |||
1065 | 101 | return this.path; | 97 | return this.path; |
1066 | 102 | } | 98 | } |
1067 | 103 | 99 | ||
1070 | 104 | public Set<Key> getGameVersions() { | 100 | public GameVersionData getGameVersions() { |
1071 | 105 | return this.versions; | 101 | return this.version; |
1072 | 106 | } | 102 | } |
1073 | 107 | 103 | ||
1074 | 108 | 104 | ||
1075 | @@ -139,23 +135,6 @@ | |||
1076 | 139 | } | 135 | } |
1077 | 140 | */ | 136 | */ |
1078 | 141 | 137 | ||
1079 | 142 | public boolean addGameVersion(GameVersionData version) { | ||
1080 | 143 | // many-to-many relationship | ||
1081 | 144 | if (this.versions.add(version.getServerKey())) | ||
1082 | 145 | { | ||
1083 | 146 | return version.getGameFiles().add(this.getServerKey()); | ||
1084 | 147 | } | ||
1085 | 148 | return false; | ||
1086 | 149 | } | ||
1087 | 150 | |||
1088 | 151 | public boolean removeGameVersion(GameVersionData version) { | ||
1089 | 152 | // many-to-many relationship | ||
1090 | 153 | if (this.versions.remove(version.getServerKey())) | ||
1091 | 154 | { | ||
1092 | 155 | return version.getGameFiles().remove(this.getServerKey()); | ||
1093 | 156 | } | ||
1094 | 157 | return false; | ||
1095 | 158 | } | ||
1096 | 159 | 138 | ||
1097 | 160 | /** TODO: Pending Blob implementation for files | 139 | /** TODO: Pending Blob implementation for files |
1098 | 161 | public GameFileData(String path, GameVersion version, InputStream contents) { | 140 | public GameFileData(String path, GameVersion version, InputStream contents) { |
1099 | @@ -183,10 +162,6 @@ | |||
1100 | 183 | public Class<GameFile> getClientClassType() { | 162 | public Class<GameFile> getClientClassType() { |
1101 | 184 | return GameFile.class; | 163 | return GameFile.class; |
1102 | 185 | } | 164 | } |
1103 | 186 | |||
1104 | 187 | public Set<Long> keysToGameVersions() { | ||
1105 | 188 | return this.fetchClientObjects(GameVersionData.class, this.versions); | ||
1106 | 189 | } | ||
1107 | 190 | 165 | ||
1108 | 191 | public String getBlobKeyString() { | 166 | public String getBlobKeyString() { |
1109 | 192 | return this.blobKey.getKeyString(); | 167 | return this.blobKey.getKeyString(); |
1110 | 193 | 168 | ||
1111 | === added file 'src/au/edu/unimelb/csse/mugle/server/model/GameFileGetter.java' | |||
1112 | --- src/au/edu/unimelb/csse/mugle/server/model/GameFileGetter.java 1970-01-01 00:00:00 +0000 | |||
1113 | +++ src/au/edu/unimelb/csse/mugle/server/model/GameFileGetter.java 2011-04-29 07:02:27 +0000 | |||
1114 | @@ -0,0 +1,116 @@ | |||
1115 | 1 | /* Melbourne University Game-based Learning Environment | ||
1116 | 2 | * Copyright (C) 2011 The University of Melbourne | ||
1117 | 3 | * | ||
1118 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1119 | 5 | * it under the terms of the GNU General Public License as published by | ||
1120 | 6 | * the Free Software Foundation, either version 3 of the License, or | ||
1121 | 7 | * (at your option) any later version. | ||
1122 | 8 | * | ||
1123 | 9 | * This program is distributed in the hope that it will be useful, | ||
1124 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1125 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1126 | 12 | * GNU General Public License for more details. | ||
1127 | 13 | * | ||
1128 | 14 | * You should have received a copy of the GNU General Public License | ||
1129 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1130 | 16 | */ | ||
1131 | 17 | |||
1132 | 18 | package au.edu.unimelb.csse.mugle.server.model; | ||
1133 | 19 | |||
1134 | 20 | import java.util.List; | ||
1135 | 21 | |||
1136 | 22 | import javax.jdo.PersistenceManager; | ||
1137 | 23 | import javax.jdo.Query; | ||
1138 | 24 | |||
1139 | 25 | import au.edu.unimelb.csse.mugle.server.PMF; | ||
1140 | 26 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameFileNotExists; | ||
1141 | 27 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameNotExists; | ||
1142 | 28 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameVersionNotExists; | ||
1143 | 29 | |||
1144 | 30 | public class GameFileGetter { | ||
1145 | 31 | /** | ||
1146 | 32 | * Gets the GameFile by its Primary Key - READ ONLY | ||
1147 | 33 | * @param primaryKey | ||
1148 | 34 | * @return the GameFile - read only | ||
1149 | 35 | * @throws GameFileNotExists | ||
1150 | 36 | */ | ||
1151 | 37 | public GameFileData getGameFile(Long primaryKey) throws GameFileNotExists { | ||
1152 | 38 | PersistenceManager pm = PMF.getManager(); | ||
1153 | 39 | try { | ||
1154 | 40 | return getGameFile(pm, primaryKey); | ||
1155 | 41 | } finally { | ||
1156 | 42 | pm.close(); | ||
1157 | 43 | } | ||
1158 | 44 | } | ||
1159 | 45 | |||
1160 | 46 | /** | ||
1161 | 47 | * Gets the GameFile by its Primary Key, for editing object in datastore | ||
1162 | 48 | * PersistenceManager must be handled by the caller | ||
1163 | 49 | * @param pm the PersistenceManager | ||
1164 | 50 | * @param primaryKey | ||
1165 | 51 | * @return the GameFile | ||
1166 | 52 | * @throws GameFileNotExists | ||
1167 | 53 | */ | ||
1168 | 54 | public GameFileData getGameFile(PersistenceManager pm, Long primaryKey) throws GameFileNotExists{ | ||
1169 | 55 | GameFileData gameFile = pm.getObjectById(GameFileData.class, primaryKey); | ||
1170 | 56 | |||
1171 | 57 | if(gameFile == null) { | ||
1172 | 58 | throw new GameFileNotExists(primaryKey); | ||
1173 | 59 | } | ||
1174 | 60 | |||
1175 | 61 | return gameFile; | ||
1176 | 62 | } | ||
1177 | 63 | |||
1178 | 64 | /** | ||
1179 | 65 | * Gets the GameFile by its path, version and game - READ ONLY | ||
1180 | 66 | * @param gameName the name of the game | ||
1181 | 67 | * @param gameVersion the version of the game | ||
1182 | 68 | * @param path the path of the file | ||
1183 | 69 | * @return the GameFile - read only | ||
1184 | 70 | * @throws GameNotExists | ||
1185 | 71 | * @throws GameVersionNotExists | ||
1186 | 72 | * @throws GameFileNotExists | ||
1187 | 73 | */ | ||
1188 | 74 | public GameFileData getGameFile(String gameName, String gameVersion, String path) | ||
1189 | 75 | throws GameNotExists, GameVersionNotExists, GameFileNotExists { | ||
1190 | 76 | PersistenceManager pm = PMF.getManager(); | ||
1191 | 77 | try { | ||
1192 | 78 | return getGameFile(pm, gameName, gameVersion, path); | ||
1193 | 79 | } finally { | ||
1194 | 80 | pm.close(); | ||
1195 | 81 | } | ||
1196 | 82 | } | ||
1197 | 83 | |||
1198 | 84 | /** | ||
1199 | 85 | * Gets the GameFile by its path, version and game, for editing object in datastore | ||
1200 | 86 | * PersistenceManager must be handled by the caller | ||
1201 | 87 | * @para pm The Persistence Manager | ||
1202 | 88 | * @param gameName the name of the game | ||
1203 | 89 | * @param gameVersion the version of the game | ||
1204 | 90 | * @param path the path of the file | ||
1205 | 91 | * @return the GameFile - read only | ||
1206 | 92 | * @throws GameNotExists | ||
1207 | 93 | * @throws GameVersionNotExists | ||
1208 | 94 | * @throws GameFileNotExists | ||
1209 | 95 | */ | ||
1210 | 96 | |||
1211 | 97 | |||
1212 | 98 | @SuppressWarnings("unchecked") | ||
1213 | 99 | public GameFileData getGameFile(PersistenceManager pm, String gameName, String gameVersion, String path) | ||
1214 | 100 | throws GameFileNotExists, GameNotExists, GameVersionNotExists { | ||
1215 | 101 | GameVersionGetter gvg = new GameVersionGetter(); | ||
1216 | 102 | GameVersionData gv = gvg.getGameVersion(pm, gameName, gameVersion); | ||
1217 | 103 | |||
1218 | 104 | |||
1219 | 105 | Query q = pm.newQuery(GameFileData.class, "path == p && version == v"); | ||
1220 | 106 | q.declareParameters("String p, GameVersionData v"); | ||
1221 | 107 | List<GameFileData> results = (List<GameFileData>) q.execute(path, gv); | ||
1222 | 108 | |||
1223 | 109 | if (results.isEmpty()) { | ||
1224 | 110 | throw new GameFileNotExists(gameName, gameVersion, path); | ||
1225 | 111 | } | ||
1226 | 112 | |||
1227 | 113 | return results.get(0); | ||
1228 | 114 | } | ||
1229 | 115 | |||
1230 | 116 | } | ||
1231 | 0 | 117 | ||
1232 | === modified file 'src/au/edu/unimelb/csse/mugle/server/model/GameVersionData.java' | |||
1233 | --- src/au/edu/unimelb/csse/mugle/server/model/GameVersionData.java 2011-04-08 11:00:59 +0000 | |||
1234 | +++ src/au/edu/unimelb/csse/mugle/server/model/GameVersionData.java 2011-04-29 07:02:27 +0000 | |||
1235 | @@ -73,16 +73,15 @@ | |||
1236 | 73 | @Element(dependent="true") | 73 | @Element(dependent="true") |
1237 | 74 | private PromotedGameData promotedGame; | 74 | private PromotedGameData promotedGame; |
1238 | 75 | 75 | ||
1239 | 76 | // Many-to-many | ||
1240 | 77 | @UserLevel(privateView=Role.DEVELOPER, publicView=Role.DEVELOPER, useMethod=true, mappedBy="keysToGameFiles") | 76 | @UserLevel(privateView=Role.DEVELOPER, publicView=Role.DEVELOPER, useMethod=true, mappedBy="keysToGameFiles") |
1243 | 78 | @Persistent | 77 | @Persistent(mappedBy="version") |
1244 | 79 | private Set<Key> gameFiles; | 78 | private Set<GameFileData> gameFiles; |
1245 | 80 | 79 | ||
1246 | 81 | // Constructors | 80 | // Constructors |
1247 | 82 | 81 | ||
1248 | 83 | public GameVersionData() { | 82 | public GameVersionData() { |
1249 | 84 | 83 | ||
1251 | 85 | this.gameFiles = new HashSet<Key>(); | 84 | this.gameFiles = new HashSet<GameFileData>(); |
1252 | 86 | this.promotedGame = null; | 85 | this.promotedGame = null; |
1253 | 87 | this.game = null; | 86 | this.game = null; |
1254 | 88 | //this.version = null; | 87 | //this.version = null; |
1255 | @@ -98,7 +97,7 @@ | |||
1256 | 98 | */ | 97 | */ |
1257 | 99 | public GameVersionData(GameData game, String displayVersion, String fullName, String description) { | 98 | public GameVersionData(GameData game, String displayVersion, String fullName, String description) { |
1258 | 100 | 99 | ||
1260 | 101 | this.gameFiles = new HashSet<Key>(); | 100 | this.gameFiles = new HashSet<GameFileData>(); |
1261 | 102 | this.promotedGame = null; | 101 | this.promotedGame = null; |
1262 | 103 | 102 | ||
1263 | 104 | /* To be unique, the Primary key must be made up of the ID of the UGP and | 103 | /* To be unique, the Primary key must be made up of the ID of the UGP and |
1264 | @@ -142,7 +141,7 @@ | |||
1265 | 142 | * } | 141 | * } |
1266 | 143 | */ | 142 | */ |
1267 | 144 | 143 | ||
1269 | 145 | public Set<Key> getGameFiles() { | 144 | public Set<GameFileData> getGameFiles() { |
1270 | 146 | return this.gameFiles; | 145 | return this.gameFiles; |
1271 | 147 | } | 146 | } |
1272 | 148 | 147 | ||
1273 | @@ -175,31 +174,6 @@ | |||
1274 | 175 | 174 | ||
1275 | 176 | // TODO: setImage(Image image); | 175 | // TODO: setImage(Image image); |
1276 | 177 | 176 | ||
1277 | 178 | |||
1278 | 179 | // Misc methods | ||
1279 | 180 | |||
1280 | 181 | public boolean addGameFile(GameFileData file) { | ||
1281 | 182 | // many-to-many relationship | ||
1282 | 183 | if (this.gameFiles.add(file.getServerKey())) { | ||
1283 | 184 | return file.getGameVersions().add(this.getServerKey()); | ||
1284 | 185 | } | ||
1285 | 186 | return false; | ||
1286 | 187 | } | ||
1287 | 188 | |||
1288 | 189 | public boolean removeGameFile(GameFileData file) { | ||
1289 | 190 | // many-to-many relationship | ||
1290 | 191 | if (this.gameFiles.remove(file.getServerKey())) { | ||
1291 | 192 | if (file.getGameVersions().remove(this.getServerKey())) | ||
1292 | 193 | { | ||
1293 | 194 | // delete file if this is the only reference | ||
1294 | 195 | if (file.getGameVersions().isEmpty()) { | ||
1295 | 196 | // TODO: delete the file off the database | ||
1296 | 197 | // is this automatically done by GAE? | ||
1297 | 198 | } | ||
1298 | 199 | } | ||
1299 | 200 | } | ||
1300 | 201 | return false; | ||
1301 | 202 | } | ||
1302 | 203 | 177 | ||
1303 | 204 | @Override | 178 | @Override |
1304 | 205 | public Key getServerKey() { | 179 | public Key getServerKey() { |
1305 | @@ -225,9 +199,9 @@ | |||
1306 | 225 | public Class<GameVersion> getClientClassType() { | 199 | public Class<GameVersion> getClientClassType() { |
1307 | 226 | return GameVersion.class; | 200 | return GameVersion.class; |
1308 | 227 | } | 201 | } |
1310 | 228 | 202 | ||
1311 | 229 | public Set<String> keysToGameFiles() { | 203 | public Set<String> keysToGameFiles() { |
1313 | 230 | return this.fetchClientObjects(GameFileData.class, this.gameFiles); | 204 | return this.fetchClientObjects(this.gameFiles); |
1314 | 231 | } | 205 | } |
1315 | 232 | 206 | ||
1316 | 233 | } | 207 | } |
1317 | 234 | 208 | ||
1318 | === added file 'src/au/edu/unimelb/csse/mugle/server/model/GameVersionGetter.java' | |||
1319 | --- src/au/edu/unimelb/csse/mugle/server/model/GameVersionGetter.java 1970-01-01 00:00:00 +0000 | |||
1320 | +++ src/au/edu/unimelb/csse/mugle/server/model/GameVersionGetter.java 2011-04-29 07:02:27 +0000 | |||
1321 | @@ -0,0 +1,107 @@ | |||
1322 | 1 | /* Melbourne University Game-based Learning Environment | ||
1323 | 2 | * Copyright (C) 2011 The University of Melbourne | ||
1324 | 3 | * | ||
1325 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1326 | 5 | * it under the terms of the GNU General Public License as published by | ||
1327 | 6 | * the Free Software Foundation, either version 3 of the License, or | ||
1328 | 7 | * (at your option) any later version. | ||
1329 | 8 | * | ||
1330 | 9 | * This program is distributed in the hope that it will be useful, | ||
1331 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1332 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1333 | 12 | * GNU General Public License for more details. | ||
1334 | 13 | * | ||
1335 | 14 | * You should have received a copy of the GNU General Public License | ||
1336 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1337 | 16 | */ | ||
1338 | 17 | |||
1339 | 18 | package au.edu.unimelb.csse.mugle.server.model; | ||
1340 | 19 | |||
1341 | 20 | import java.util.List; | ||
1342 | 21 | |||
1343 | 22 | import javax.jdo.PersistenceManager; | ||
1344 | 23 | import javax.jdo.Query; | ||
1345 | 24 | |||
1346 | 25 | import au.edu.unimelb.csse.mugle.server.PMF; | ||
1347 | 26 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameNotExists; | ||
1348 | 27 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameVersionNotExists; | ||
1349 | 28 | |||
1350 | 29 | public class GameVersionGetter { | ||
1351 | 30 | /** | ||
1352 | 31 | * Gets the GameVersion by its Primary Key - READ ONLY | ||
1353 | 32 | * @param primaryKey | ||
1354 | 33 | * @return the GameVersion - read only | ||
1355 | 34 | * @throws GameVersionNotExists | ||
1356 | 35 | */ | ||
1357 | 36 | public GameVersionData getGameVersion(Long primaryKey) throws GameVersionNotExists { | ||
1358 | 37 | PersistenceManager pm = PMF.getManager(); | ||
1359 | 38 | try { | ||
1360 | 39 | return getGameVersion(pm, primaryKey); | ||
1361 | 40 | } finally { | ||
1362 | 41 | pm.close(); | ||
1363 | 42 | } | ||
1364 | 43 | } | ||
1365 | 44 | |||
1366 | 45 | /** | ||
1367 | 46 | * Gets the GameVersion by its Primary Key, for editing object in datstore | ||
1368 | 47 | * PersistenceManager must be handled by the caller | ||
1369 | 48 | * @param pm the PersistenceManager | ||
1370 | 49 | * @param primaryKey | ||
1371 | 50 | * @return the GameVersion | ||
1372 | 51 | * @throws GameVersionNotExists | ||
1373 | 52 | */ | ||
1374 | 53 | public GameVersionData getGameVersion(PersistenceManager pm, Long primaryKey) throws GameVersionNotExists{ | ||
1375 | 54 | GameVersionData gameversion = pm.getObjectById(GameVersionData.class, primaryKey); | ||
1376 | 55 | |||
1377 | 56 | if(gameversion == null) { | ||
1378 | 57 | throw new GameVersionNotExists(primaryKey); | ||
1379 | 58 | } | ||
1380 | 59 | |||
1381 | 60 | return gameversion; | ||
1382 | 61 | } | ||
1383 | 62 | |||
1384 | 63 | /** | ||
1385 | 64 | * Gets the GameVersion by its display Version - READ ONLY | ||
1386 | 65 | * @param gameName the name of the Game that it belongs to | ||
1387 | 66 | * @param dispVersion the displayed version number | ||
1388 | 67 | * @return the GameVersion - read only | ||
1389 | 68 | * @throws GameVersionNotExists | ||
1390 | 69 | */ | ||
1391 | 70 | public GameVersionData getGameVersion(String gameName, String dispVersion) | ||
1392 | 71 | throws GameVersionNotExists, GameNotExists { | ||
1393 | 72 | PersistenceManager pm = PMF.getManager(); | ||
1394 | 73 | try { | ||
1395 | 74 | return getGameVersion(pm, gameName, dispVersion); | ||
1396 | 75 | } finally { | ||
1397 | 76 | pm.close(); | ||
1398 | 77 | } | ||
1399 | 78 | } | ||
1400 | 79 | |||
1401 | 80 | /** | ||
1402 | 81 | * Gets the GameVersion by its display name, for editing object in datastore | ||
1403 | 82 | * PersistenceManager must be handled by the caller | ||
1404 | 83 | * @param pm the PersistenceManager | ||
1405 | 84 | * @param gameName the name of the Game that it belongs to | ||
1406 | 85 | * @param dispVersion the displayed version number | ||
1407 | 86 | * @return the GameVersion | ||
1408 | 87 | * @throws GameVersionNotExists | ||
1409 | 88 | * @throws GameNotExists | ||
1410 | 89 | */ | ||
1411 | 90 | @SuppressWarnings("unchecked") | ||
1412 | 91 | public GameVersionData getGameVersion(PersistenceManager pm, String gameName, String dispVersion) | ||
1413 | 92 | throws GameVersionNotExists, GameNotExists{ | ||
1414 | 93 | GameGetter g = new GameGetter(); | ||
1415 | 94 | GameData game = g.getGame(pm, gameName); | ||
1416 | 95 | |||
1417 | 96 | Query q = pm.newQuery(GameData.class, "dispVersion == d && game == g"); | ||
1418 | 97 | q.declareParameters("String d, GameData g"); | ||
1419 | 98 | List<GameVersionData> results = (List<GameVersionData>) q.execute(dispVersion, game); | ||
1420 | 99 | |||
1421 | 100 | if(results.isEmpty()) { | ||
1422 | 101 | throw new GameNotExists(dispVersion, game.getUrlName()); | ||
1423 | 102 | } | ||
1424 | 103 | |||
1425 | 104 | return results.get(0); | ||
1426 | 105 | } | ||
1427 | 106 | } | ||
1428 | 107 | |||
1429 | 0 | 108 | ||
1430 | === modified file 'src/au/edu/unimelb/csse/mugle/server/model/KeyValuePairGetter.java' | |||
1431 | --- src/au/edu/unimelb/csse/mugle/server/model/KeyValuePairGetter.java 2011-04-29 07:02:27 +0000 | |||
1432 | +++ src/au/edu/unimelb/csse/mugle/server/model/KeyValuePairGetter.java 2011-04-29 07:02:27 +0000 | |||
1433 | @@ -16,6 +16,8 @@ | |||
1434 | 16 | */ | 16 | */ |
1435 | 17 | package au.edu.unimelb.csse.mugle.server.model; | 17 | package au.edu.unimelb.csse.mugle.server.model; |
1436 | 18 | 18 | ||
1437 | 19 | import java.util.List; | ||
1438 | 20 | |||
1439 | 19 | import javax.jdo.PersistenceManager; | 21 | import javax.jdo.PersistenceManager; |
1440 | 20 | import javax.jdo.Query; | 22 | import javax.jdo.Query; |
1441 | 21 | 23 | ||
1442 | @@ -37,7 +39,7 @@ | |||
1443 | 37 | * @throws KeyError | 39 | * @throws KeyError |
1444 | 38 | */ | 40 | */ |
1445 | 39 | public KeyValuePairData getKeyValuePair(String key, String gameToken) | 41 | public KeyValuePairData getKeyValuePair(String key, String gameToken) |
1447 | 40 | throws UserNotExists, GameTokenError, KeyError { | 42 | throws GameTokenError, KeyError { |
1448 | 41 | PersistenceManager pm = PMF.getManager(); | 43 | PersistenceManager pm = PMF.getManager(); |
1449 | 42 | try { | 44 | try { |
1450 | 43 | return getKeyValuePair(pm, key, gameToken); | 45 | return getKeyValuePair(pm, key, gameToken); |
1451 | @@ -60,7 +62,7 @@ | |||
1452 | 60 | * @throws KeyError | 62 | * @throws KeyError |
1453 | 61 | */ | 63 | */ |
1454 | 62 | public KeyValuePairData getKeyValuePair(PersistenceManager pm, String key, String gameToken) | 64 | public KeyValuePairData getKeyValuePair(PersistenceManager pm, String key, String gameToken) |
1456 | 63 | throws UserNotExists, GameTokenError, KeyError { | 65 | throws GameTokenError, KeyError { |
1457 | 64 | return getKeyValuePair(pm, key, gameToken, false); | 66 | return getKeyValuePair(pm, key, gameToken, false); |
1458 | 65 | } | 67 | } |
1459 | 66 | 68 | ||
1460 | @@ -79,30 +81,32 @@ | |||
1461 | 79 | * @throws GameTokenError | 81 | * @throws GameTokenError |
1462 | 80 | * @throws KeyError | 82 | * @throws KeyError |
1463 | 81 | */ | 83 | */ |
1464 | 84 | @SuppressWarnings("unchecked") | ||
1465 | 82 | public KeyValuePairData getKeyValuePair(PersistenceManager pm, String key, String gameToken, boolean createIfNotFound) | 85 | public KeyValuePairData getKeyValuePair(PersistenceManager pm, String key, String gameToken, boolean createIfNotFound) |
1467 | 83 | throws UserNotExists, GameTokenError, KeyError { | 86 | throws GameTokenError, KeyError { |
1468 | 84 | UserGameProfileGetter u = new UserGameProfileGetter(); | 87 | UserGameProfileGetter u = new UserGameProfileGetter(); |
1469 | 85 | UserGameProfileData ugp = u.getCurrentUserGameProfile(pm, gameToken); | 88 | UserGameProfileData ugp = u.getCurrentUserGameProfile(pm, gameToken); |
1470 | 86 | 89 | ||
1471 | 87 | KeyValuePairData kvp = null; | ||
1472 | 88 | |||
1473 | 89 | Query q = pm.newQuery(KeyValuePairData.class, "key == k && ugp == u"); | 90 | Query q = pm.newQuery(KeyValuePairData.class, "key == k && ugp == u"); |
1474 | 90 | q.declareParameters("String k, UserGameProfileData u"); | 91 | q.declareParameters("String k, UserGameProfileData u"); |
1476 | 91 | kvp = (KeyValuePairData) q.execute(key, ugp); | 92 | List<KeyValuePairData> results = (List<KeyValuePairData>) q.execute(key, ugp); |
1477 | 92 | 93 | ||
1478 | 93 | /* If the key value pair isn't found - we want to create one if | 94 | /* If the key value pair isn't found - we want to create one if |
1479 | 94 | * createIfNotFound is set to true | 95 | * createIfNotFound is set to true |
1480 | 95 | */ | 96 | */ |
1482 | 96 | if (kvp == null) { | 97 | if (results.isEmpty()) { |
1483 | 97 | if (createIfNotFound) { | 98 | if (createIfNotFound) { |
1485 | 98 | kvp = new KeyValuePairData(); | 99 | KeyValuePairData kvp = new KeyValuePairData(); |
1486 | 99 | kvp.setKey(key); | 100 | kvp.setKey(key); |
1487 | 100 | kvp.setUserGameProfile(ugp); | 101 | kvp.setUserGameProfile(ugp); |
1488 | 102 | pm.makePersistent(kvp); | ||
1489 | 103 | |||
1490 | 104 | results.add(kvp); | ||
1491 | 101 | } else { | 105 | } else { |
1492 | 102 | throw new KeyError(key); | 106 | throw new KeyError(key); |
1493 | 103 | } | 107 | } |
1494 | 104 | } | 108 | } |
1495 | 105 | 109 | ||
1497 | 106 | return kvp; | 110 | return results.get(0); |
1498 | 107 | } | 111 | } |
1499 | 108 | } | 112 | } |
1500 | 109 | 113 | ||
1501 | === modified file 'src/au/edu/unimelb/csse/mugle/server/model/ModelDataClass.java' | |||
1502 | --- src/au/edu/unimelb/csse/mugle/server/model/ModelDataClass.java 2011-04-29 07:02:27 +0000 | |||
1503 | +++ src/au/edu/unimelb/csse/mugle/server/model/ModelDataClass.java 2011-04-29 07:02:27 +0000 | |||
1504 | @@ -98,5 +98,17 @@ | |||
1505 | 98 | return list; | 98 | return list; |
1506 | 99 | 99 | ||
1507 | 100 | } | 100 | } |
1508 | 101 | |||
1509 | 102 | protected <A, C extends ModelDataClass<A,?,C>> Set<A> fetchClientObjects(Set<C> dataList) { | ||
1510 | 103 | |||
1511 | 104 | HashSet<A> list = new HashSet<A>(dataList.size()); | ||
1512 | 105 | |||
1513 | 106 | for (C cls : dataList) { | ||
1514 | 107 | list.add(cls.getPrimaryKey()); | ||
1515 | 108 | } | ||
1516 | 109 | |||
1517 | 110 | return list; | ||
1518 | 111 | |||
1519 | 112 | } | ||
1520 | 101 | 113 | ||
1521 | 102 | } | 114 | } |
1522 | 103 | 115 | ||
1523 | === modified file 'src/au/edu/unimelb/csse/mugle/server/model/ModelWrapper.java' | |||
1524 | --- src/au/edu/unimelb/csse/mugle/server/model/ModelWrapper.java 2011-04-29 07:02:27 +0000 | |||
1525 | +++ src/au/edu/unimelb/csse/mugle/server/model/ModelWrapper.java 2011-04-29 07:02:27 +0000 | |||
1526 | @@ -20,11 +20,17 @@ | |||
1527 | 20 | import java.lang.reflect.*; | 20 | import java.lang.reflect.*; |
1528 | 21 | 21 | ||
1529 | 22 | import javax.jdo.PersistenceManager; | 22 | import javax.jdo.PersistenceManager; |
1530 | 23 | import javax.jdo.Query; | ||
1531 | 24 | |||
1532 | 25 | import com.google.appengine.api.users.User; | ||
1533 | 26 | import com.google.appengine.api.users.UserService; | ||
1534 | 27 | import com.google.appengine.api.users.UserServiceFactory; | ||
1535 | 23 | 28 | ||
1536 | 24 | import au.edu.unimelb.csse.mugle.server.model.annotations.*; | 29 | import au.edu.unimelb.csse.mugle.server.model.annotations.*; |
1537 | 25 | import au.edu.unimelb.csse.mugle.server.PMF; | 30 | import au.edu.unimelb.csse.mugle.server.PMF; |
1538 | 26 | import au.edu.unimelb.csse.mugle.shared.model.*; | 31 | import au.edu.unimelb.csse.mugle.shared.model.*; |
1539 | 27 | import au.edu.unimelb.csse.mugle.shared.model.annotations.*; | 32 | import au.edu.unimelb.csse.mugle.shared.model.annotations.*; |
1540 | 33 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.ServerException; | ||
1541 | 28 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.UserPrivilegeException; | 34 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.UserPrivilegeException; |
1542 | 29 | 35 | ||
1543 | 30 | public final class ModelWrapper { | 36 | public final class ModelWrapper { |
1544 | @@ -58,7 +64,7 @@ | |||
1545 | 58 | case DEVELOPER: | 64 | case DEVELOPER: |
1546 | 59 | return (role == Role.ADMIN || role == Role.DEVELOPER); | 65 | return (role == Role.ADMIN || role == Role.DEVELOPER); |
1547 | 60 | 66 | ||
1549 | 61 | case USER: | 67 | case GUEST: |
1550 | 62 | return true; | 68 | return true; |
1551 | 63 | 69 | ||
1552 | 64 | default: | 70 | default: |
1553 | @@ -168,8 +174,8 @@ | |||
1554 | 168 | * @throws IllegalArgumentException | 174 | * @throws IllegalArgumentException |
1555 | 169 | * @throws NoSuchMethodException | 175 | * @throws NoSuchMethodException |
1556 | 170 | */ | 176 | */ |
1559 | 171 | public static <T extends ModelClass<?,T>, U extends ModelDataClass<?,T,U>, B extends ModelClass<?,B>, C extends ModelDataClass<?,B,C>> | 177 | public static <T extends ModelClass<?,T>, U extends ModelDataClass<?,T,U>> |
1560 | 172 | T getClientClone(U obj, Role role, ClientView cview) | 178 | T getClientClone(U obj, Role role, ClientView cview) |
1561 | 173 | throws InstantiationException, IllegalAccessException, SecurityException, | 179 | throws InstantiationException, IllegalAccessException, SecurityException, |
1562 | 174 | NoSuchFieldException, NoSuchMethodException, IllegalArgumentException, | 180 | NoSuchFieldException, NoSuchMethodException, IllegalArgumentException, |
1563 | 175 | InvocationTargetException { | 181 | InvocationTargetException { |
1564 | @@ -230,6 +236,37 @@ | |||
1565 | 230 | return stripped; | 236 | return stripped; |
1566 | 231 | 237 | ||
1567 | 232 | } | 238 | } |
1568 | 239 | |||
1569 | 240 | public static <T extends ModelClass<?,T>, U extends ModelDataClass<?,T,U>> | ||
1570 | 241 | T getClientCloneSafe(U obj, Role role, ClientView cview) | ||
1571 | 242 | throws ServerException { | ||
1572 | 243 | |||
1573 | 244 | try { | ||
1574 | 245 | return getClientClone(obj, role, cview); | ||
1575 | 246 | } catch (SecurityException e) { | ||
1576 | 247 | e.printStackTrace(); | ||
1577 | 248 | throw new ServerException(e.getMessage()); | ||
1578 | 249 | } catch (IllegalArgumentException e) { | ||
1579 | 250 | e.printStackTrace(); | ||
1580 | 251 | throw new ServerException(e.getMessage()); | ||
1581 | 252 | } catch (InstantiationException e) { | ||
1582 | 253 | e.printStackTrace(); | ||
1583 | 254 | throw new ServerException(e.getMessage()); | ||
1584 | 255 | } catch (IllegalAccessException e) { | ||
1585 | 256 | e.printStackTrace(); | ||
1586 | 257 | throw new ServerException(e.getMessage()); | ||
1587 | 258 | } catch (NoSuchFieldException e) { | ||
1588 | 259 | e.printStackTrace(); | ||
1589 | 260 | throw new ServerException(e.getMessage()); | ||
1590 | 261 | } catch (NoSuchMethodException e) { | ||
1591 | 262 | e.printStackTrace(); | ||
1592 | 263 | throw new ServerException(e.getMessage()); | ||
1593 | 264 | } catch (InvocationTargetException e) { | ||
1594 | 265 | e.printStackTrace(); | ||
1595 | 266 | throw new ServerException(e.getMessage()); | ||
1596 | 267 | } | ||
1597 | 268 | |||
1598 | 269 | } | ||
1599 | 233 | 270 | ||
1600 | 234 | /** | 271 | /** |
1601 | 235 | * Converts a ModelClass instance to its counter part ModelDataClass, | 272 | * Converts a ModelClass instance to its counter part ModelDataClass, |
1602 | @@ -655,10 +692,22 @@ | |||
1603 | 655 | 692 | ||
1604 | 656 | 693 | ||
1605 | 657 | // Current login privileges | 694 | // Current login privileges |
1607 | 658 | 695 | ||
1608 | 659 | public static Role getCurrentRole() { | 696 | public static Role getCurrentRole() { |
1611 | 660 | // TODO needs to actually check login details and return the actual role. | 697 | |
1612 | 661 | return Role.USER; | 698 | UserService userService = UserServiceFactory.getUserService(); |
1613 | 699 | User user = userService.getCurrentUser(); | ||
1614 | 700 | |||
1615 | 701 | PersistenceManager pm = PMF.getManager(); | ||
1616 | 702 | if (pm == null) { return Role.NONE; } | ||
1617 | 703 | |||
1618 | 704 | Query q = pm.newQuery(UserData.class, "googleID == i || email == e"); | ||
1619 | 705 | q.declareParameters("String i, String e"); | ||
1620 | 706 | UserData ud = (UserData) q.execute(user.getUserId(), user.getEmail()); | ||
1621 | 707 | if (ud == null) { return Role.NONE; } | ||
1622 | 708 | |||
1623 | 709 | return ud.getRole(); | ||
1624 | 710 | |||
1625 | 662 | } | 711 | } |
1626 | 663 | 712 | ||
1627 | 664 | public static ClientView getCurrentClientView() { | 713 | public static ClientView getCurrentClientView() { |
1628 | 665 | 714 | ||
1629 | === modified file 'src/au/edu/unimelb/csse/mugle/server/model/UserAchievementGetter.java' | |||
1630 | --- src/au/edu/unimelb/csse/mugle/server/model/UserAchievementGetter.java 2011-04-29 07:02:27 +0000 | |||
1631 | +++ src/au/edu/unimelb/csse/mugle/server/model/UserAchievementGetter.java 2011-04-29 07:02:27 +0000 | |||
1632 | @@ -17,6 +17,8 @@ | |||
1633 | 17 | 17 | ||
1634 | 18 | package au.edu.unimelb.csse.mugle.server.model; | 18 | package au.edu.unimelb.csse.mugle.server.model; |
1635 | 19 | 19 | ||
1636 | 20 | import java.util.List; | ||
1637 | 21 | |||
1638 | 20 | import javax.jdo.PersistenceManager; | 22 | import javax.jdo.PersistenceManager; |
1639 | 21 | import javax.jdo.Query; | 23 | import javax.jdo.Query; |
1640 | 22 | 24 | ||
1641 | @@ -37,7 +39,7 @@ | |||
1642 | 37 | * @throws AchievementNotExists | 39 | * @throws AchievementNotExists |
1643 | 38 | */ | 40 | */ |
1644 | 39 | public UserAchievementData getUserAchievement(String achievementName, String gameToken) | 41 | public UserAchievementData getUserAchievement(String achievementName, String gameToken) |
1646 | 40 | throws UserNotExists, GameTokenError, AchievementNotExists { | 42 | throws GameTokenError, AchievementNotExists { |
1647 | 41 | PersistenceManager pm = PMF.getManager(); | 43 | PersistenceManager pm = PMF.getManager(); |
1648 | 42 | try { | 44 | try { |
1649 | 43 | return getUserAchievement(pm, achievementName, gameToken); | 45 | return getUserAchievement(pm, achievementName, gameToken); |
1650 | @@ -58,8 +60,9 @@ | |||
1651 | 58 | * @throws GameTokenError | 60 | * @throws GameTokenError |
1652 | 59 | * @throws AchievementNotExists | 61 | * @throws AchievementNotExists |
1653 | 60 | */ | 62 | */ |
1654 | 63 | @SuppressWarnings("unchecked") | ||
1655 | 61 | public UserAchievementData getUserAchievement(PersistenceManager pm, String achievementName, String gameToken) | 64 | public UserAchievementData getUserAchievement(PersistenceManager pm, String achievementName, String gameToken) |
1657 | 62 | throws UserNotExists, GameTokenError, AchievementNotExists { | 65 | throws GameTokenError, AchievementNotExists { |
1658 | 63 | UserGameProfileGetter u = new UserGameProfileGetter(); | 66 | UserGameProfileGetter u = new UserGameProfileGetter(); |
1659 | 64 | AchievementGetter a = new AchievementGetter(); | 67 | AchievementGetter a = new AchievementGetter(); |
1660 | 65 | 68 | ||
1661 | @@ -68,17 +71,20 @@ | |||
1662 | 68 | 71 | ||
1663 | 69 | Query q = pm.newQuery(UserAchievementData.class, "ugp == u && achievement == a"); | 72 | Query q = pm.newQuery(UserAchievementData.class, "ugp == u && achievement == a"); |
1664 | 70 | q.declareParameters("UserGameProfileData ugp, AchievementData a"); | 73 | q.declareParameters("UserGameProfileData ugp, AchievementData a"); |
1666 | 71 | UserAchievementData ua = (UserAchievementData) q.execute(ugp, achievement); | 74 | List<UserAchievementData> results = (List<UserAchievementData>) q.execute(ugp, achievement); |
1667 | 72 | 75 | ||
1668 | 73 | /* If we can't find the UserAchievement it makes sense to create one | 76 | /* If we can't find the UserAchievement it makes sense to create one |
1669 | 74 | * if the UserGameProfile and the Achievement exist. | 77 | * if the UserGameProfile and the Achievement exist. |
1670 | 75 | */ | 78 | */ |
1673 | 76 | if (ua == null) { | 79 | if (results.isEmpty()) { |
1674 | 77 | ua = new UserAchievementData(); | 80 | UserAchievementData ua = new UserAchievementData(); |
1675 | 78 | ua.setAchievement(achievement); | 81 | ua.setAchievement(achievement); |
1676 | 79 | ua.setUserGameProfile(ugp); | 82 | ua.setUserGameProfile(ugp); |
1677 | 83 | pm.makePersistent(ua); | ||
1678 | 84 | |||
1679 | 85 | results.add(ua); | ||
1680 | 80 | } | 86 | } |
1681 | 81 | 87 | ||
1683 | 82 | return ua; | 88 | return results.get(0); |
1684 | 83 | } | 89 | } |
1685 | 84 | } | 90 | } |
1686 | 85 | 91 | ||
1687 | === modified file 'src/au/edu/unimelb/csse/mugle/server/model/UserGameProfileGetter.java' | |||
1688 | --- src/au/edu/unimelb/csse/mugle/server/model/UserGameProfileGetter.java 2011-04-29 07:02:27 +0000 | |||
1689 | +++ src/au/edu/unimelb/csse/mugle/server/model/UserGameProfileGetter.java 2011-04-29 07:02:27 +0000 | |||
1690 | @@ -17,6 +17,8 @@ | |||
1691 | 17 | 17 | ||
1692 | 18 | package au.edu.unimelb.csse.mugle.server.model; | 18 | package au.edu.unimelb.csse.mugle.server.model; |
1693 | 19 | 19 | ||
1694 | 20 | import java.util.List; | ||
1695 | 21 | |||
1696 | 20 | import javax.jdo.PersistenceManager; | 22 | import javax.jdo.PersistenceManager; |
1697 | 21 | import javax.jdo.Query; | 23 | import javax.jdo.Query; |
1698 | 22 | 24 | ||
1699 | @@ -68,7 +70,7 @@ | |||
1700 | 68 | * @throws GameTokenError | 70 | * @throws GameTokenError |
1701 | 69 | */ | 71 | */ |
1702 | 70 | public UserGameProfileData getCurrentUserGameProfile(String gameToken) | 72 | public UserGameProfileData getCurrentUserGameProfile(String gameToken) |
1704 | 71 | throws UserNotExists, GameTokenError { | 73 | throws GameTokenError { |
1705 | 72 | PersistenceManager pm = PMF.getManager(); | 74 | PersistenceManager pm = PMF.getManager(); |
1706 | 73 | try { | 75 | try { |
1707 | 74 | return getCurrentUserGameProfile(pm, gameToken); | 76 | return getCurrentUserGameProfile(pm, gameToken); |
1708 | @@ -87,27 +89,31 @@ | |||
1709 | 87 | * @throws UserNotExists | 89 | * @throws UserNotExists |
1710 | 88 | * @throws GameTokenError | 90 | * @throws GameTokenError |
1711 | 89 | */ | 91 | */ |
1712 | 92 | @SuppressWarnings("unchecked") | ||
1713 | 90 | public UserGameProfileData getCurrentUserGameProfile(PersistenceManager pm, String gameToken) | 93 | public UserGameProfileData getCurrentUserGameProfile(PersistenceManager pm, String gameToken) |
1715 | 91 | throws UserNotExists, GameTokenError { | 94 | throws GameTokenError { |
1716 | 92 | UserGetter u = new UserGetter(); | 95 | UserGetter u = new UserGetter(); |
1717 | 93 | GameGetter g = new GameGetter(); | 96 | GameGetter g = new GameGetter(); |
1718 | 94 | UserData curUser = u.getCurrentUser(pm); | 97 | UserData curUser = u.getCurrentUser(pm); |
1719 | 95 | GameData curGame = g.getCurrentGame(pm, gameToken); | 98 | GameData curGame = g.getCurrentGame(pm, gameToken); |
1721 | 96 | UserGameProfileData ugp = null; | 99 | |
1722 | 97 | 100 | ||
1723 | 98 | Query q = pm.newQuery(UserGameProfileData.class, "user == u && game == g"); | 101 | Query q = pm.newQuery(UserGameProfileData.class, "user == u && game == g"); |
1724 | 99 | q.declareParameters("UserData u, GameData g"); | 102 | q.declareParameters("UserData u, GameData g"); |
1726 | 100 | ugp = (UserGameProfileData) q.execute(curUser, curGame); | 103 | List<UserGameProfileData> results = (List<UserGameProfileData>) q.execute(curUser, curGame); |
1727 | 101 | 104 | ||
1728 | 102 | /* If we can't find the UserGameProfile it makes sense to create one | 105 | /* If we can't find the UserGameProfile it makes sense to create one |
1729 | 103 | * if the user is playing the game | 106 | * if the user is playing the game |
1730 | 104 | */ | 107 | */ |
1733 | 105 | if (ugp == null) { | 108 | if (results.isEmpty()) { |
1734 | 106 | ugp = new UserGameProfileData(); | 109 | UserGameProfileData ugp = new UserGameProfileData(); |
1735 | 107 | ugp.setGame(curGame); | 110 | ugp.setGame(curGame); |
1736 | 108 | ugp.setUser(curUser); | 111 | ugp.setUser(curUser); |
1737 | 112 | pm.makePersistent(ugp); | ||
1738 | 113 | |||
1739 | 114 | results.add(ugp); | ||
1740 | 109 | } | 115 | } |
1742 | 110 | return ugp; | 116 | return results.get(0); |
1743 | 111 | } | 117 | } |
1744 | 112 | 118 | ||
1745 | 113 | } | 119 | } |
1746 | 114 | 120 | ||
1747 | === modified file 'src/au/edu/unimelb/csse/mugle/server/model/UserGetter.java' | |||
1748 | --- src/au/edu/unimelb/csse/mugle/server/model/UserGetter.java 2011-04-29 07:02:27 +0000 | |||
1749 | +++ src/au/edu/unimelb/csse/mugle/server/model/UserGetter.java 2011-04-29 07:02:27 +0000 | |||
1750 | @@ -20,9 +20,12 @@ | |||
1751 | 20 | import javax.jdo.PersistenceManager; | 20 | import javax.jdo.PersistenceManager; |
1752 | 21 | import javax.jdo.Query; | 21 | import javax.jdo.Query; |
1753 | 22 | 22 | ||
1754 | 23 | import java.util.List; | ||
1755 | 24 | |||
1756 | 23 | import au.edu.unimelb.csse.mugle.client.LoginInfo; | 25 | import au.edu.unimelb.csse.mugle.client.LoginInfo; |
1758 | 24 | import au.edu.unimelb.csse.mugle.server.LoginServiceImpl; | 26 | import au.edu.unimelb.csse.mugle.server.ClientServiceImpl; |
1759 | 25 | import au.edu.unimelb.csse.mugle.server.PMF; | 27 | import au.edu.unimelb.csse.mugle.server.PMF; |
1760 | 28 | import au.edu.unimelb.csse.mugle.shared.model.Role; | ||
1761 | 26 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.UserNotExists; | 29 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.UserNotExists; |
1762 | 27 | 30 | ||
1763 | 28 | public class UserGetter { | 31 | public class UserGetter { |
1764 | @@ -82,16 +85,17 @@ | |||
1765 | 82 | * @return The User class | 85 | * @return The User class |
1766 | 83 | * @throws UserNotExists | 86 | * @throws UserNotExists |
1767 | 84 | */ | 87 | */ |
1768 | 88 | @SuppressWarnings("unchecked") | ||
1769 | 85 | public UserData getUserByName(PersistenceManager pm, String name) throws UserNotExists { | 89 | public UserData getUserByName(PersistenceManager pm, String name) throws UserNotExists { |
1770 | 86 | Query q = pm.newQuery(UserData.class, "urlName == u"); | 90 | Query q = pm.newQuery(UserData.class, "urlName == u"); |
1771 | 87 | q.declareParameters("String u"); | 91 | q.declareParameters("String u"); |
1773 | 88 | UserData u = (UserData) q.execute(name); | 92 | List<UserData> results = (List<UserData>) q.execute(name); |
1774 | 89 | 93 | ||
1776 | 90 | if (u == null) { | 94 | if (results.isEmpty()) { |
1777 | 91 | throw new UserNotExists(name); | 95 | throw new UserNotExists(name); |
1778 | 92 | } | 96 | } |
1779 | 93 | 97 | ||
1781 | 94 | return u; | 98 | return results.get(0); |
1782 | 95 | } | 99 | } |
1783 | 96 | 100 | ||
1784 | 97 | /** | 101 | /** |
1785 | @@ -117,24 +121,24 @@ | |||
1786 | 117 | * @return The User class | 121 | * @return The User class |
1787 | 118 | * @throws UserNotExists | 122 | * @throws UserNotExists |
1788 | 119 | */ | 123 | */ |
1789 | 124 | @SuppressWarnings("unchecked") | ||
1790 | 120 | public UserData getUser(PersistenceManager pm, String googleID) throws UserNotExists { | 125 | public UserData getUser(PersistenceManager pm, String googleID) throws UserNotExists { |
1791 | 121 | Query q = pm.newQuery(UserData.class, "googleID == u"); | 126 | Query q = pm.newQuery(UserData.class, "googleID == u"); |
1792 | 122 | q.declareParameters("String u"); | 127 | q.declareParameters("String u"); |
1794 | 123 | UserData u = (UserData) q.execute(googleID); | 128 | List<UserData> results = (List<UserData>) q.execute(googleID); |
1795 | 124 | 129 | ||
1797 | 125 | if (u == null) { | 130 | if (results.isEmpty()) { |
1798 | 126 | throw new UserNotExists(googleID); | 131 | throw new UserNotExists(googleID); |
1799 | 127 | } | 132 | } |
1800 | 128 | 133 | ||
1802 | 129 | return u; | 134 | return results.get(0); |
1803 | 130 | } | 135 | } |
1804 | 131 | 136 | ||
1805 | 132 | /** | 137 | /** |
1806 | 133 | * Gets the currently logged in User - READ ONLY | 138 | * Gets the currently logged in User - READ ONLY |
1807 | 134 | * @return the User - read only | 139 | * @return the User - read only |
1808 | 135 | * @throws UserNotExists | ||
1809 | 136 | */ | 140 | */ |
1811 | 137 | public UserData getCurrentUser() throws UserNotExists { | 141 | public UserData getCurrentUser() { |
1812 | 138 | PersistenceManager pm = PMF.getManager(); | 142 | PersistenceManager pm = PMF.getManager(); |
1813 | 139 | try { | 143 | try { |
1814 | 140 | return getCurrentUser(pm); | 144 | return getCurrentUser(pm); |
1815 | @@ -144,17 +148,35 @@ | |||
1816 | 144 | } | 148 | } |
1817 | 145 | 149 | ||
1818 | 146 | /** | 150 | /** |
1820 | 147 | * Gets the currently logged in User, for editing object in datstore | 151 | * Gets the currently logged in User, for editing object in datastore |
1821 | 152 | * Creates a new user if the currently logged in user is not found | ||
1822 | 148 | * Persistence Manager must be handled by the caller | 153 | * Persistence Manager must be handled by the caller |
1823 | 149 | * @param pm The Persistence Manager | 154 | * @param pm The Persistence Manager |
1824 | 150 | * @return the current User | 155 | * @return the current User |
1825 | 151 | * @throws UserNotExists | ||
1826 | 152 | */ | 156 | */ |
1829 | 153 | public UserData getCurrentUser(PersistenceManager pm) throws UserNotExists { | 157 | public UserData getCurrentUser(PersistenceManager pm) { |
1830 | 154 | LoginServiceImpl loginService = new LoginServiceImpl(); | 158 | ClientServiceImpl loginService = new ClientServiceImpl(); |
1831 | 155 | LoginInfo loginInfo = loginService.getCurrentUser(); | 159 | LoginInfo loginInfo = loginService.getCurrentUser(); |
1832 | 156 | 160 | ||
1834 | 157 | return getUser(pm, loginInfo.getUserID()); | 161 | try { |
1835 | 162 | return getUser(pm, loginInfo.getUserID()); | ||
1836 | 163 | } catch (UserNotExists e) { | ||
1837 | 164 | UserData newUser = new UserData(); | ||
1838 | 165 | |||
1839 | 166 | //Creates the new user using the info provided by google | ||
1840 | 167 | newUser.setGoogleID(loginInfo.getUserID()); | ||
1841 | 168 | newUser.setUrlName(loginInfo.getNickname()); | ||
1842 | 169 | newUser.setFullName(loginInfo.getNickname()); | ||
1843 | 170 | newUser.setEmail(loginInfo.getEmailAddress()); | ||
1844 | 171 | newUser.setRole(Role.DEVELOPER); | ||
1845 | 172 | newUser.setActive(true); | ||
1846 | 173 | |||
1847 | 174 | //Stores the new user in the datastore | ||
1848 | 175 | pm.makePersistent(newUser); | ||
1849 | 176 | |||
1850 | 177 | return newUser; | ||
1851 | 178 | } | ||
1852 | 179 | |||
1853 | 158 | } | 180 | } |
1854 | 159 | 181 | ||
1855 | 160 | } | 182 | } |
1856 | 161 | 183 | ||
1857 | === modified file 'src/au/edu/unimelb/csse/mugle/server/model/annotations/UserLevel.java' | |||
1858 | --- src/au/edu/unimelb/csse/mugle/server/model/annotations/UserLevel.java 2011-03-31 09:56:28 +0000 | |||
1859 | +++ src/au/edu/unimelb/csse/mugle/server/model/annotations/UserLevel.java 2011-04-29 07:02:27 +0000 | |||
1860 | @@ -27,8 +27,8 @@ | |||
1861 | 27 | @Target(ElementType.FIELD) | 27 | @Target(ElementType.FIELD) |
1862 | 28 | @Retention(RetentionPolicy.RUNTIME) | 28 | @Retention(RetentionPolicy.RUNTIME) |
1863 | 29 | public @interface UserLevel { | 29 | public @interface UserLevel { |
1866 | 30 | Role privateView() default Role.USER; | 30 | Role privateView() default Role.GUEST; |
1867 | 31 | Role publicView() default Role.USER; | 31 | Role publicView() default Role.GUEST; |
1868 | 32 | boolean useMethod() default false; | 32 | boolean useMethod() default false; |
1869 | 33 | boolean mapField() default true; | 33 | boolean mapField() default true; |
1870 | 34 | String mappedBy() default ""; | 34 | String mappedBy() default ""; |
1871 | 35 | 35 | ||
1872 | === modified file 'src/au/edu/unimelb/csse/mugle/server/platform/DeveloperServiceImpl.java' | |||
1873 | --- src/au/edu/unimelb/csse/mugle/server/platform/DeveloperServiceImpl.java 2011-04-29 07:02:27 +0000 | |||
1874 | +++ src/au/edu/unimelb/csse/mugle/server/platform/DeveloperServiceImpl.java 2011-04-29 07:02:27 +0000 | |||
1875 | @@ -23,7 +23,7 @@ | |||
1876 | 23 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.*; | 23 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.*; |
1877 | 24 | 24 | ||
1878 | 25 | @SuppressWarnings("serial") | 25 | @SuppressWarnings("serial") |
1880 | 26 | public class DeveloperServiceImpl extends UserServiceImpl implements DeveloperService { | 26 | public class DeveloperServiceImpl extends GuestServiceImpl implements DeveloperService { |
1881 | 27 | 27 | ||
1882 | 28 | @Override | 28 | @Override |
1883 | 29 | public GameVersion addGameVersion(GameVersion gameVersion) | 29 | public GameVersion addGameVersion(GameVersion gameVersion) |
1884 | 30 | 30 | ||
1885 | === renamed file 'src/au/edu/unimelb/csse/mugle/server/platform/UserServiceImpl.java' => 'src/au/edu/unimelb/csse/mugle/server/platform/GuestServiceImpl.java' | |||
1886 | --- src/au/edu/unimelb/csse/mugle/server/platform/UserServiceImpl.java 2011-03-26 14:01:07 +0000 | |||
1887 | +++ src/au/edu/unimelb/csse/mugle/server/platform/GuestServiceImpl.java 2011-04-29 07:02:27 +0000 | |||
1888 | @@ -19,9 +19,21 @@ | |||
1889 | 19 | 19 | ||
1890 | 20 | import com.google.gwt.user.server.rpc.RemoteServiceServlet; | 20 | import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
1891 | 21 | 21 | ||
1893 | 22 | import au.edu.unimelb.csse.mugle.client.platform.UserService; | 22 | import au.edu.unimelb.csse.mugle.client.platform.GuestService; |
1894 | 23 | import au.edu.unimelb.csse.mugle.server.model.*; | ||
1895 | 24 | import au.edu.unimelb.csse.mugle.shared.model.*; | ||
1896 | 25 | import au.edu.unimelb.csse.mugle.shared.platform.exceptions.ServerException; | ||
1897 | 23 | 26 | ||
1898 | 24 | @SuppressWarnings("serial") | 27 | @SuppressWarnings("serial") |
1900 | 25 | public class UserServiceImpl extends RemoteServiceServlet implements UserService { | 28 | public class GuestServiceImpl extends RemoteServiceServlet implements GuestService { |
1901 | 29 | |||
1902 | 30 | @Override | ||
1903 | 31 | public User getCurrentUserDetails() throws ServerException { | ||
1904 | 32 | |||
1905 | 33 | UserGetter u = new UserGetter(); | ||
1906 | 34 | UserData ud = u.getCurrentUser(); | ||
1907 | 35 | |||
1908 | 36 | return ModelWrapper.getClientCloneSafe(ud, ud.getRole(), ClientView.PRIVATE); | ||
1909 | 37 | } | ||
1910 | 26 | 38 | ||
1911 | 27 | } | 39 | } |
1912 | 28 | 40 | ||
1913 | === modified file 'src/au/edu/unimelb/csse/mugle/shared/model/DataServiceAsync.java' | |||
1914 | --- src/au/edu/unimelb/csse/mugle/shared/model/DataServiceAsync.java 2011-04-08 09:52:55 +0000 | |||
1915 | +++ src/au/edu/unimelb/csse/mugle/shared/model/DataServiceAsync.java 2011-04-29 07:02:27 +0000 | |||
1916 | @@ -26,7 +26,7 @@ | |||
1917 | 26 | 26 | ||
1918 | 27 | void fetchDevTeams(Set<Long> keys, AsyncCallback<Set<DevTeam>> callback); | 27 | void fetchDevTeams(Set<Long> keys, AsyncCallback<Set<DevTeam>> callback); |
1919 | 28 | 28 | ||
1921 | 29 | void fetchGameFiles(Set<String> keys, AsyncCallback<Set<GameFile>> callback); | 29 | void fetchGameFiles(Set<Long> keys, AsyncCallback<Set<GameFile>> callback); |
1922 | 30 | 30 | ||
1923 | 31 | void fetchGames(Set<Long> keys, AsyncCallback<Set<Game>> callback); | 31 | void fetchGames(Set<Long> keys, AsyncCallback<Set<Game>> callback); |
1924 | 32 | 32 | ||
1925 | 33 | 33 | ||
1926 | === modified file 'src/au/edu/unimelb/csse/mugle/shared/model/GameFile.java' | |||
1927 | --- src/au/edu/unimelb/csse/mugle/shared/model/GameFile.java 2011-04-29 07:02:27 +0000 | |||
1928 | +++ src/au/edu/unimelb/csse/mugle/shared/model/GameFile.java 2011-04-29 07:02:27 +0000 | |||
1929 | @@ -17,10 +17,6 @@ | |||
1930 | 17 | 17 | ||
1931 | 18 | package au.edu.unimelb.csse.mugle.shared.model; | 18 | package au.edu.unimelb.csse.mugle.shared.model; |
1932 | 19 | 19 | ||
1933 | 20 | import java.util.Set; | ||
1934 | 21 | |||
1935 | 22 | import com.google.gwt.user.client.rpc.AsyncCallback; | ||
1936 | 23 | |||
1937 | 24 | import au.edu.unimelb.csse.mugle.shared.model.annotations.*; | 20 | import au.edu.unimelb.csse.mugle.shared.model.annotations.*; |
1938 | 25 | 21 | ||
1939 | 26 | @MugleDataWrapper | 22 | @MugleDataWrapper |
1940 | @@ -36,11 +32,11 @@ | |||
1941 | 36 | 32 | ||
1942 | 37 | private String blobKey; //key to the actual blob | 33 | private String blobKey; //key to the actual blob |
1943 | 38 | 34 | ||
1945 | 39 | private Set<Long> gameVersionKeys; //Game versions this file belongs to | 35 | private GameVersion version; //Game versions this file belongs to |
1946 | 40 | 36 | ||
1947 | 41 | // Constructors | 37 | // Constructors |
1948 | 42 | public GameFile() { | 38 | public GameFile() { |
1950 | 43 | this.gameVersionKeys = null; | 39 | this.version = null; |
1951 | 44 | this.mimeType = null; | 40 | this.mimeType = null; |
1952 | 45 | this.blobKey = null; | 41 | this.blobKey = null; |
1953 | 46 | this.path = null; | 42 | this.path = null; |
1954 | @@ -52,12 +48,8 @@ | |||
1955 | 52 | return this.path; | 48 | return this.path; |
1956 | 53 | } | 49 | } |
1957 | 54 | 50 | ||
1964 | 55 | public Set<Long> getGameVersionKeys() { | 51 | public GameVersion getGameVersionKeys() { |
1965 | 56 | return this.gameVersionKeys; | 52 | return this.version; |
1960 | 57 | } | ||
1961 | 58 | |||
1962 | 59 | public void fetchGameVersions(AsyncCallback<Set<GameVersion>> callback) { | ||
1963 | 60 | DataProvider.getService().fetchGameVersions(this.gameVersionKeys, callback); | ||
1966 | 61 | } | 53 | } |
1967 | 62 | 54 | ||
1968 | 63 | @Override | 55 | @Override |
1969 | @@ -71,8 +63,8 @@ | |||
1970 | 71 | this.path = path; | 63 | this.path = path; |
1971 | 72 | } | 64 | } |
1972 | 73 | 65 | ||
1975 | 74 | public void setGameVersionKeys(Set<Long> versions) { | 66 | public void setGameVersionKeys(GameVersion version) { |
1976 | 75 | this.gameVersionKeys = versions; | 67 | this.version = version; |
1977 | 76 | } | 68 | } |
1978 | 77 | 69 | ||
1979 | 78 | public void setMimeType(String mimeType) { | 70 | public void setMimeType(String mimeType) { |
1980 | 79 | 71 | ||
1981 | === modified file 'src/au/edu/unimelb/csse/mugle/shared/model/GameVersion.java' | |||
1982 | --- src/au/edu/unimelb/csse/mugle/shared/model/GameVersion.java 2011-04-29 07:02:27 +0000 | |||
1983 | +++ src/au/edu/unimelb/csse/mugle/shared/model/GameVersion.java 2011-04-29 07:02:27 +0000 | |||
1984 | @@ -49,7 +49,7 @@ | |||
1985 | 49 | 49 | ||
1986 | 50 | private PromotedGame promotedGame; | 50 | private PromotedGame promotedGame; |
1987 | 51 | 51 | ||
1989 | 52 | private Set<String> gameFileKeys; | 52 | private Set<Long> gameFileKeys; |
1990 | 53 | 53 | ||
1991 | 54 | // Constructors | 54 | // Constructors |
1992 | 55 | 55 | ||
1993 | @@ -95,7 +95,7 @@ | |||
1994 | 95 | return this.promotedGame; | 95 | return this.promotedGame; |
1995 | 96 | } | 96 | } |
1996 | 97 | 97 | ||
1998 | 98 | public Set<String> getGameFileKeys() { | 98 | public Set<Long> getGameFileKeys() { |
1999 | 99 | return this.gameFileKeys; | 99 | return this.gameFileKeys; |
2000 | 100 | } | 100 | } |
2001 | 101 | 101 | ||
2002 | @@ -130,7 +130,7 @@ | |||
2003 | 130 | this.promotedGame = promotedGame; | 130 | this.promotedGame = promotedGame; |
2004 | 131 | } | 131 | } |
2005 | 132 | 132 | ||
2007 | 133 | public void setGameFileKeys(Set<String> gameFiles) { | 133 | public void setGameFileKeys(Set<Long> gameFiles) { |
2008 | 134 | this.gameFileKeys = gameFiles; | 134 | this.gameFileKeys = gameFiles; |
2009 | 135 | } | 135 | } |
2010 | 136 | 136 | ||
2011 | 137 | 137 | ||
2012 | === modified file 'src/au/edu/unimelb/csse/mugle/shared/model/ModelClass.java' | |||
2013 | --- src/au/edu/unimelb/csse/mugle/shared/model/ModelClass.java 2011-03-30 15:46:59 +0000 | |||
2014 | +++ src/au/edu/unimelb/csse/mugle/shared/model/ModelClass.java 2011-04-29 07:02:27 +0000 | |||
2015 | @@ -19,17 +19,20 @@ | |||
2016 | 19 | 19 | ||
2017 | 20 | import java.io.Serializable; | 20 | import java.io.Serializable; |
2018 | 21 | 21 | ||
2019 | 22 | import com.google.gwt.user.client.rpc.IsSerializable; | ||
2020 | 23 | |||
2021 | 22 | /** | 24 | /** |
2022 | 23 | * Base model class that should be extended by all shared model class entities. | 25 | * Base model class that should be extended by all shared model class entities. |
2023 | 24 | * @param <S> The primary key type | 26 | * @param <S> The primary key type |
2024 | 25 | * @param <T> The client class type (usually self type) | 27 | * @param <T> The client class type (usually self type) |
2025 | 26 | * @param <U> The server class type (usually the data counter part type) | 28 | * @param <U> The server class type (usually the data counter part type) |
2026 | 27 | */ | 29 | */ |
2027 | 28 | @SuppressWarnings("serial") | ||
2028 | 29 | public abstract class ModelClass<S,T extends ModelClass<S,?>> implements Serializable { | ||
2029 | 30 | |||
2030 | 31 | 30 | ||
2032 | 32 | private S id = null; | 31 | public abstract class ModelClass<S,T extends ModelClass<S,?>> implements Serializable, IsSerializable { |
2033 | 32 | |||
2034 | 33 | private static final long serialVersionUID = -2271296896173152105L; | ||
2035 | 34 | |||
2036 | 35 | private S id = null; | ||
2037 | 33 | 36 | ||
2038 | 34 | /** | 37 | /** |
2039 | 35 | * The getter for the primary key | 38 | * The getter for the primary key |
2040 | 36 | 39 | ||
2041 | === modified file 'src/au/edu/unimelb/csse/mugle/shared/model/Role.java' | |||
2042 | --- src/au/edu/unimelb/csse/mugle/shared/model/Role.java 2011-03-10 04:56:07 +0000 | |||
2043 | +++ src/au/edu/unimelb/csse/mugle/shared/model/Role.java 2011-04-29 07:02:27 +0000 | |||
2044 | @@ -18,5 +18,5 @@ | |||
2045 | 18 | package au.edu.unimelb.csse.mugle.shared.model; | 18 | package au.edu.unimelb.csse.mugle.shared.model; |
2046 | 19 | 19 | ||
2047 | 20 | public enum Role { | 20 | public enum Role { |
2049 | 21 | USER, DEVELOPER, ADMIN; | 21 | NONE, GUEST, DEVELOPER, ADMIN; |
2050 | 22 | } | 22 | } |
2051 | 23 | 23 | ||
2052 | === modified file 'src/au/edu/unimelb/csse/mugle/shared/model/annotations/MugleDataWrapper.java' | |||
2053 | --- src/au/edu/unimelb/csse/mugle/shared/model/annotations/MugleDataWrapper.java 2011-03-30 15:46:59 +0000 | |||
2054 | +++ src/au/edu/unimelb/csse/mugle/shared/model/annotations/MugleDataWrapper.java 2011-04-29 07:02:27 +0000 | |||
2055 | @@ -31,10 +31,10 @@ | |||
2056 | 31 | @Target(ElementType.TYPE) | 31 | @Target(ElementType.TYPE) |
2057 | 32 | @Retention(RetentionPolicy.RUNTIME) | 32 | @Retention(RetentionPolicy.RUNTIME) |
2058 | 33 | public @interface MugleDataWrapper { | 33 | public @interface MugleDataWrapper { |
2065 | 34 | Role privateAdd() default Role.USER; | 34 | Role privateAdd() default Role.GUEST; |
2066 | 35 | Role privateUpdate() default Role.USER; | 35 | Role privateUpdate() default Role.GUEST; |
2067 | 36 | Role privateRemove() default Role.USER; | 36 | Role privateRemove() default Role.GUEST; |
2068 | 37 | Role publicAdd() default Role.USER; | 37 | Role publicAdd() default Role.GUEST; |
2069 | 38 | Role publicUpdate() default Role.USER; | 38 | Role publicUpdate() default Role.GUEST; |
2070 | 39 | Role publicRemove() default Role.USER; | 39 | Role publicRemove() default Role.GUEST; |
2071 | 40 | } | 40 | } |
2072 | 41 | 41 | ||
2073 | === added file 'src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameFileNotExists.java' | |||
2074 | --- src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameFileNotExists.java 1970-01-01 00:00:00 +0000 | |||
2075 | +++ src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameFileNotExists.java 2011-04-29 07:02:27 +0000 | |||
2076 | @@ -0,0 +1,22 @@ | |||
2077 | 1 | package au.edu.unimelb.csse.mugle.shared.platform.exceptions; | ||
2078 | 2 | |||
2079 | 3 | public class GameFileNotExists extends Exception{ | ||
2080 | 4 | |||
2081 | 5 | /** | ||
2082 | 6 | * | ||
2083 | 7 | */ | ||
2084 | 8 | private static final long serialVersionUID = 728229816363066583L; | ||
2085 | 9 | |||
2086 | 10 | public GameFileNotExists() { | ||
2087 | 11 | super(); | ||
2088 | 12 | } | ||
2089 | 13 | |||
2090 | 14 | public GameFileNotExists(Long primaryKey) { | ||
2091 | 15 | super("The gameFile with primary key " + primaryKey.toString() + " does not exist"); | ||
2092 | 16 | } | ||
2093 | 17 | |||
2094 | 18 | public GameFileNotExists(String gameName, String gameVersion, String path) { | ||
2095 | 19 | super("The file " + path + " for the version " + gameVersion + | ||
2096 | 20 | " of " + gameName + " does not Exist."); | ||
2097 | 21 | } | ||
2098 | 22 | } | ||
2099 | 0 | 23 | ||
2100 | === modified file 'src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameNotExists.java' | |||
2101 | --- src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameNotExists.java 2011-04-29 07:02:27 +0000 | |||
2102 | +++ src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameNotExists.java 2011-04-29 07:02:27 +0000 | |||
2103 | @@ -46,5 +46,9 @@ | |||
2104 | 46 | public GameNotExists(Long id) { | 46 | public GameNotExists(Long id) { |
2105 | 47 | super("Game with ID '" + id + "' does not exist."); | 47 | super("Game with ID '" + id + "' does not exist."); |
2106 | 48 | } | 48 | } |
2107 | 49 | |||
2108 | 50 | public GameNotExists(String dispVersion, String gameName) { | ||
2109 | 51 | super("Game " + gameName + " does not have version " + dispVersion + "."); | ||
2110 | 52 | } | ||
2111 | 49 | 53 | ||
2112 | 50 | } | 54 | } |
2113 | 51 | \ No newline at end of file | 55 | \ No newline at end of file |
2114 | 52 | 56 | ||
2115 | === added file 'src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/ServerException.java' | |||
2116 | --- src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/ServerException.java 1970-01-01 00:00:00 +0000 | |||
2117 | +++ src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/ServerException.java 2011-04-29 07:02:27 +0000 | |||
2118 | @@ -0,0 +1,34 @@ | |||
2119 | 1 | /* Melbourne University Game-based Learning Environment | ||
2120 | 2 | * Copyright (C) 2011 The University of Melbourne | ||
2121 | 3 | * | ||
2122 | 4 | * This program is free software: you can redistribute it and/or modify | ||
2123 | 5 | * it under the terms of the GNU General Public License as published by | ||
2124 | 6 | * the Free Software Foundation, either version 3 of the License, or | ||
2125 | 7 | * (at your option) any later version. | ||
2126 | 8 | * | ||
2127 | 9 | * This program is distributed in the hope that it will be useful, | ||
2128 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2129 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2130 | 12 | * GNU General Public License for more details. | ||
2131 | 13 | * | ||
2132 | 14 | * You should have received a copy of the GNU General Public License | ||
2133 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2134 | 16 | */ | ||
2135 | 17 | |||
2136 | 18 | package au.edu.unimelb.csse.mugle.shared.platform.exceptions; | ||
2137 | 19 | |||
2138 | 20 | import java.io.Serializable; | ||
2139 | 21 | |||
2140 | 22 | public class ServerException extends Exception implements Serializable { | ||
2141 | 23 | |||
2142 | 24 | private static final long serialVersionUID = -5641489622969459865L; | ||
2143 | 25 | |||
2144 | 26 | public ServerException() { | ||
2145 | 27 | super(); | ||
2146 | 28 | } | ||
2147 | 29 | |||
2148 | 30 | public ServerException(final String msg) { | ||
2149 | 31 | super(msg); | ||
2150 | 32 | } | ||
2151 | 33 | |||
2152 | 34 | } | ||
2153 | 0 | 35 | ||
2154 | === modified file 'war/Mugle.css' | |||
2155 | --- war/Mugle.css 2011-04-08 11:51:46 +0000 | |||
2156 | +++ war/Mugle.css 2011-04-29 07:02:27 +0000 | |||
2157 | @@ -1,7 +1,8 @@ | |||
2158 | 1 | /** Add css rules here for your application. */ | 1 | /** Add css rules here for your application. */ |
2159 | 2 | 2 | ||
2160 | 3 | body { | 3 | body { |
2162 | 4 | min-width: 600px; | 4 | min-width: 1000px; |
2163 | 5 | background: white; | ||
2164 | 5 | } | 6 | } |
2165 | 6 | 7 | ||
2166 | 7 | h1 { | 8 | h1 { |
2167 | @@ -12,54 +13,103 @@ | |||
2168 | 12 | text-align: center; | 13 | text-align: center; |
2169 | 13 | } | 14 | } |
2170 | 14 | 15 | ||
2171 | 16 | #container { | ||
2172 | 17 | min-height: 100%; | ||
2173 | 18 | width: 100%; | ||
2174 | 19 | position: relative; | ||
2175 | 20 | float: left; | ||
2176 | 21 | } | ||
2177 | 22 | |||
2178 | 23 | /* HEADER */ | ||
2179 | 24 | |||
2180 | 15 | #user-panel-container { | 25 | #user-panel-container { |
2181 | 16 | height: 25px; | 26 | height: 25px; |
2182 | 17 | border-bottom: #b6bac0 1px solid; | 27 | border-bottom: #b6bac0 1px solid; |
2183 | 18 | margin: 0; | 28 | margin: 0; |
2186 | 19 | padding: 0 5px; | 29 | padding: 0; |
2187 | 20 | background-color: #ffffff; | 30 | background: white; |
2188 | 31 | position: relative; | ||
2189 | 32 | float: left; | ||
2190 | 33 | width: 100%; | ||
2191 | 21 | } | 34 | } |
2192 | 22 | 35 | ||
2193 | 23 | #user-panel-title { | 36 | #user-panel-title { |
2194 | 24 | height: 25px; | 37 | height: 25px; |
2195 | 25 | width:50px; | 38 | width:50px; |
2197 | 26 | margin: 0; | 39 | margin: 5px 5px 0 5px; |
2198 | 27 | padding: 0; | 40 | padding: 0; |
2199 | 28 | float: left; | 41 | float: left; |
2200 | 29 | padding-top: 5px; | ||
2201 | 30 | } | 42 | } |
2202 | 31 | 43 | ||
2203 | 32 | #user-panel-holder { | 44 | #user-panel-holder { |
2204 | 33 | height: 25px; | 45 | height: 25px; |
2205 | 34 | margin: 0; | 46 | margin: 0; |
2207 | 35 | padding: 0; | 47 | padding: 0 5px; |
2208 | 36 | float: right; | 48 | float: right; |
2209 | 37 | text-align: : right; | 49 | text-align: : right; |
2210 | 38 | } | 50 | } |
2211 | 39 | 51 | ||
2212 | 52 | /* BODY */ | ||
2213 | 53 | |||
2214 | 40 | #main-panel { | 54 | #main-panel { |
2230 | 41 | text-align: center; | 55 | padding:0; |
2231 | 42 | min-height:500px; | 56 | padding-bottom:100px; /* Height of the footer */ |
2232 | 43 | height:100%; | 57 | background:white; |
2233 | 44 | background-color: #ffffff; | 58 | position: relative; |
2234 | 45 | } | 59 | float: left; |
2220 | 46 | |||
2221 | 47 | table#tools-panel { | ||
2222 | 48 | position: absolute; | ||
2223 | 49 | left: 0; | ||
2224 | 50 | top: 25px; | ||
2225 | 51 | width: 250px; | ||
2226 | 52 | } | ||
2227 | 53 | |||
2228 | 54 | #error-display { | ||
2229 | 55 | background-color: #ffffff; | ||
2235 | 56 | width: 100%; | 60 | width: 100%; |
2236 | 57 | } | 61 | } |
2237 | 58 | 62 | ||
2238 | 63 | #main-panel-container { | ||
2239 | 64 | clear:left; | ||
2240 | 65 | float:left; | ||
2241 | 66 | width:100%; | ||
2242 | 67 | overflow:hidden; | ||
2243 | 68 | background:white; /* column 2 background colour */ | ||
2244 | 69 | } | ||
2245 | 70 | |||
2246 | 71 | #main-panel-container-inner { | ||
2247 | 72 | float:left; | ||
2248 | 73 | width:100%; | ||
2249 | 74 | position:relative; | ||
2250 | 75 | right:80%; | ||
2251 | 76 | background:white; /* column 1 background colour */ | ||
2252 | 77 | border-right: #b6bac0 1px solid; | ||
2253 | 78 | min-height: 500px; | ||
2254 | 79 | } | ||
2255 | 80 | |||
2256 | 81 | #tools-panel { | ||
2257 | 82 | float:left; | ||
2258 | 83 | width:20%; | ||
2259 | 84 | position:relative; | ||
2260 | 85 | left:80%; | ||
2261 | 86 | overflow:hidden; | ||
2262 | 87 | } | ||
2263 | 88 | |||
2264 | 89 | #right-panel { | ||
2265 | 90 | float:left; | ||
2266 | 91 | width:80%; | ||
2267 | 92 | position:relative; | ||
2268 | 93 | left:80%; | ||
2269 | 94 | overflow:hidden; | ||
2270 | 95 | } | ||
2271 | 96 | |||
2272 | 97 | #right-panel-inner { | ||
2273 | 98 | float:left; | ||
2274 | 99 | width:100%; | ||
2275 | 100 | margin:5px; | ||
2276 | 101 | } | ||
2277 | 102 | |||
2278 | 103 | /* FOOTER */ | ||
2279 | 104 | |||
2280 | 59 | #footer { | 105 | #footer { |
2281 | 106 | position:absolute; | ||
2282 | 107 | /*position: relative;*/ | ||
2283 | 108 | width: 100%; | ||
2284 | 109 | bottom: 0; | ||
2285 | 60 | text-align: center; | 110 | text-align: center; |
2286 | 61 | background: #01467d url('img/footer-top.png') top center repeat-x; | 111 | background: #01467d url('img/footer-top.png') top center repeat-x; |
2288 | 62 | height: 100px; | 112 | height: 100px; /* Height of the footer */ |
2289 | 63 | } | 113 | } |
2290 | 64 | 114 | ||
2291 | 65 | #footer-banner { | 115 | #footer-banner { |
2292 | @@ -80,6 +130,11 @@ | |||
2293 | 80 | float: right; | 130 | float: right; |
2294 | 81 | } | 131 | } |
2295 | 82 | 132 | ||
2296 | 133 | #error-display { | ||
2297 | 134 | background-color: #ffffff; | ||
2298 | 135 | width: 100%; | ||
2299 | 136 | } | ||
2300 | 137 | |||
2301 | 83 | .sendButton { | 138 | .sendButton { |
2302 | 84 | display: block; | 139 | display: block; |
2303 | 85 | font-size: 16pt; | 140 | font-size: 16pt; |
2304 | 86 | 141 | ||
2305 | === modified file 'war/Mugle.html' | |||
2306 | --- war/Mugle.html 2011-04-02 04:18:20 +0000 | |||
2307 | +++ war/Mugle.html 2011-04-29 07:02:27 +0000 | |||
2308 | @@ -30,7 +30,10 @@ | |||
2309 | 30 | <!-- Consider inlining CSS to reduce the number of requested files --> | 30 | <!-- Consider inlining CSS to reduce the number of requested files --> |
2310 | 31 | <!-- --> | 31 | <!-- --> |
2311 | 32 | <link type="text/css" rel="stylesheet" href="Mugle.css"> | 32 | <link type="text/css" rel="stylesheet" href="Mugle.css"> |
2313 | 33 | 33 | <!--[if lte IE 6]> | |
2314 | 34 | <link type="text/css" rel="stylesheet" href="MugleIE6.css"> | ||
2315 | 35 | <![endif]--> | ||
2316 | 36 | |||
2317 | 34 | <!-- --> | 37 | <!-- --> |
2318 | 35 | <!-- Any title is fine --> | 38 | <!-- Any title is fine --> |
2319 | 36 | <!-- --> | 39 | <!-- --> |
2320 | @@ -62,28 +65,34 @@ | |||
2321 | 62 | </div> | 65 | </div> |
2322 | 63 | </noscript> | 66 | </noscript> |
2323 | 64 | 67 | ||
2346 | 65 | <div id="user-panel-container"> | 68 | <div id="container"> |
2347 | 66 | <div id="user-panel-title"></div> | 69 | |
2348 | 67 | <div id="user-panel-holder"></div> | 70 | <div id="user-panel-container"> |
2349 | 68 | </div> | 71 | <div id="user-panel-title"></div> |
2350 | 69 | 72 | <div id="user-panel-holder"></div> | |
2351 | 70 | <div id="main-panel"></div> | 73 | </div> |
2352 | 71 | 74 | ||
2353 | 72 | <table id="error-display" align="center"> | 75 | <div id="main-panel"> |
2354 | 73 | <tr> | 76 | <!-- All GWT elements gets added/removed in here. --> |
2355 | 74 | <td colspan="2" style="color:red;" id="errorLabelContainer"></td> | 77 | </div> |
2356 | 75 | </tr> | 78 | |
2357 | 76 | </table> | 79 | <table id="error-display" align="center"> |
2358 | 77 | 80 | <tr> | |
2359 | 78 | <div id="footer"> | 81 | <td colspan="2" style="color:red;" id="errorLabelContainer"></td> |
2360 | 79 | <div id="footer-banner"> | 82 | </tr> |
2361 | 80 | <a id="unimelb-logo" href="http://www.unimelb.edu.au" title="University of Melbourne" target="_blank"> | 83 | </table> |
2362 | 81 | <img src="img/unimelb.png"></img> | 84 | |
2363 | 82 | </a> | 85 | <div id="footer"> |
2364 | 83 | <div id="footer-content"> | 86 | <div id="footer-banner"> |
2365 | 84 | <!-- Add copyright details, etc --> | 87 | <a id="unimelb-logo" href="http://www.unimelb.edu.au" title="University of Melbourne" target="_blank"> |
2366 | 85 | </div> | 88 | <img src="img/unimelb.png"></img> |
2367 | 86 | </div> | 89 | </a> |
2368 | 90 | <div id="footer-content"> | ||
2369 | 91 | <!-- Add copyright details, etc --> | ||
2370 | 92 | </div> | ||
2371 | 93 | </div> | ||
2372 | 94 | </div> | ||
2373 | 95 | |||
2374 | 87 | </div> | 96 | </div> |
2375 | 88 | 97 | ||
2376 | 89 | </body> | 98 | </body> |
2377 | 90 | 99 | ||
2378 | === added file 'war/MugleIE6.css' | |||
2379 | --- war/MugleIE6.css 1970-01-01 00:00:00 +0000 | |||
2380 | +++ war/MugleIE6.css 2011-04-29 07:02:27 +0000 | |||
2381 | @@ -0,0 +1,3 @@ | |||
2382 | 1 | #container { | ||
2383 | 2 | height:100%; | ||
2384 | 3 | } | ||
2385 | 0 | \ No newline at end of file | 4 | \ No newline at end of file |
2386 | 1 | 5 | ||
2387 | === modified file 'war/WEB-INF/web.xml' | |||
2388 | --- war/WEB-INF/web.xml 2011-04-29 07:02:27 +0000 | |||
2389 | +++ war/WEB-INF/web.xml 2011-04-29 07:02:27 +0000 | |||
2390 | @@ -12,13 +12,13 @@ | |||
2391 | 12 | <!-- Servlets --> | 12 | <!-- Servlets --> |
2392 | 13 | 13 | ||
2393 | 14 | <servlet> | 14 | <servlet> |
2396 | 15 | <servlet-name>LoginService</servlet-name> | 15 | <servlet-name>ClientService</servlet-name> |
2397 | 16 | <servlet-class>au.edu.unimelb.csse.mugle.server.LoginServiceImpl</servlet-class> | 16 | <servlet-class>au.edu.unimelb.csse.mugle.server.ClientServiceImpl</servlet-class> |
2398 | 17 | </servlet> | 17 | </servlet> |
2399 | 18 | 18 | ||
2400 | 19 | <servlet-mapping> | 19 | <servlet-mapping> |
2403 | 20 | <servlet-name>LoginService</servlet-name> | 20 | <servlet-name>ClientService</servlet-name> |
2404 | 21 | <url-pattern>/mugle/login</url-pattern> | 21 | <url-pattern>/mugle/client</url-pattern> |
2405 | 22 | </servlet-mapping> | 22 | </servlet-mapping> |
2406 | 23 | 23 | ||
2407 | 24 | <servlet> | 24 | <servlet> |
2408 | @@ -52,13 +52,13 @@ | |||
2409 | 52 | </servlet-mapping> | 52 | </servlet-mapping> |
2410 | 53 | 53 | ||
2411 | 54 | <servlet> | 54 | <servlet> |
2414 | 55 | <servlet-name>UserService</servlet-name> | 55 | <servlet-name>GuestService</servlet-name> |
2415 | 56 | <servlet-class>au.edu.unimelb.csse.mugle.server.platform.UserServiceImpl</servlet-class> | 56 | <servlet-class>au.edu.unimelb.csse.mugle.server.platform.GuestServiceImpl</servlet-class> |
2416 | 57 | </servlet> | 57 | </servlet> |
2417 | 58 | 58 | ||
2418 | 59 | <servlet-mapping> | 59 | <servlet-mapping> |
2421 | 60 | <servlet-name>UserService</servlet-name> | 60 | <servlet-name>GuestService</servlet-name> |
2422 | 61 | <url-pattern>/mugle/users</url-pattern> | 61 | <url-pattern>/mugle/guests</url-pattern> |
2423 | 62 | </servlet-mapping> | 62 | </servlet-mapping> |
2424 | 63 | 63 | ||
2425 | 64 | <servlet> | 64 | <servlet> |
Let's just do it.