Merge lp:~mugle-dev/mugle/dev-api into lp:mugle

Proposed by Scott Ritchie
Status: Merged
Merged at revision: 101
Proposed branch: lp:~mugle-dev/mugle/dev-api
Merge into: lp:mugle
Diff against target: 3635 lines (+2637/-71)
70 files modified
doc/dev/api.rst (+36/-0)
doc/dev/index.rst (+2/-0)
doc/platform/datastore-access.rst (+80/-0)
doc/platform/index.rst (+1/-0)
src/au/edu/unimelb/csse/mugle/client/LoginInfo.java (+9/-0)
src/au/edu/unimelb/csse/mugle/client/api/BadgeService.java (+101/-0)
src/au/edu/unimelb/csse/mugle/client/api/BadgeServiceAsync.java (+102/-0)
src/au/edu/unimelb/csse/mugle/client/api/HighscoreService.java (+46/-0)
src/au/edu/unimelb/csse/mugle/client/api/HighscoreServiceAsync.java (+44/-0)
src/au/edu/unimelb/csse/mugle/client/api/KeyValueService.java (+63/-0)
src/au/edu/unimelb/csse/mugle/client/api/KeyValueServiceAsync.java (+61/-0)
src/au/edu/unimelb/csse/mugle/client/api/Services.java (+50/-0)
src/au/edu/unimelb/csse/mugle/client/api/UserService.java (+41/-0)
src/au/edu/unimelb/csse/mugle/client/api/UserServiceAsync.java (+43/-0)
src/au/edu/unimelb/csse/mugle/client/ui/MugleUiBuilder.java (+144/-0)
src/au/edu/unimelb/csse/mugle/client/ui/PageNav.java (+78/-0)
src/au/edu/unimelb/csse/mugle/server/DataTestServiceImpl.java (+0/-1)
src/au/edu/unimelb/csse/mugle/server/LoginServiceImpl.java (+21/-0)
src/au/edu/unimelb/csse/mugle/server/PMF.java (+1/-1)
src/au/edu/unimelb/csse/mugle/server/api/BadgeServiceImpl.java (+149/-0)
src/au/edu/unimelb/csse/mugle/server/api/HighscoreServiceImpl.java (+65/-0)
src/au/edu/unimelb/csse/mugle/server/api/KeyValueServiceImpl.java (+89/-0)
src/au/edu/unimelb/csse/mugle/server/api/UserServiceImpl.java (+58/-0)
src/au/edu/unimelb/csse/mugle/server/model/AchievementData.java (+20/-6)
src/au/edu/unimelb/csse/mugle/server/model/AchievementGetter.java (+109/-0)
src/au/edu/unimelb/csse/mugle/server/model/DevTeamGetter.java (+78/-0)
src/au/edu/unimelb/csse/mugle/server/model/GameData.java (+12/-1)
src/au/edu/unimelb/csse/mugle/server/model/GameFileData.java (+30/-1)
src/au/edu/unimelb/csse/mugle/server/model/GameGetter.java (+132/-0)
src/au/edu/unimelb/csse/mugle/server/model/KeyValuePairData.java (+6/-0)
src/au/edu/unimelb/csse/mugle/server/model/KeyValuePairGetter.java (+108/-0)
src/au/edu/unimelb/csse/mugle/server/model/ModelDataClass.java (+1/-1)
src/au/edu/unimelb/csse/mugle/server/model/ModelWrapper.java (+1/-1)
src/au/edu/unimelb/csse/mugle/server/model/UserAchievementData.java (+11/-5)
src/au/edu/unimelb/csse/mugle/server/model/UserAchievementGetter.java (+84/-0)
src/au/edu/unimelb/csse/mugle/server/model/UserData.java (+14/-0)
src/au/edu/unimelb/csse/mugle/server/model/UserGameProfileGetter.java (+113/-0)
src/au/edu/unimelb/csse/mugle/server/model/UserGetter.java (+160/-0)
src/au/edu/unimelb/csse/mugle/server/platform/AdminServiceImpl.java (+1/-0)
src/au/edu/unimelb/csse/mugle/server/platform/DeveloperServiceImpl.java (+1/-0)
src/au/edu/unimelb/csse/mugle/server/platform/ServiceHelper.java (+1/-0)
src/au/edu/unimelb/csse/mugle/shared/api/Badge.java (+85/-0)
src/au/edu/unimelb/csse/mugle/shared/api/BadgeError.java (+34/-0)
src/au/edu/unimelb/csse/mugle/shared/api/GameTokenError.java (+34/-0)
src/au/edu/unimelb/csse/mugle/shared/api/KeyError.java (+43/-0)
src/au/edu/unimelb/csse/mugle/shared/model/Achievement.java (+16/-4)
src/au/edu/unimelb/csse/mugle/shared/model/DevTeam.java (+2/-2)
src/au/edu/unimelb/csse/mugle/shared/model/Game.java (+15/-3)
src/au/edu/unimelb/csse/mugle/shared/model/GameFile.java (+26/-4)
src/au/edu/unimelb/csse/mugle/shared/model/GameVersion.java (+2/-1)
src/au/edu/unimelb/csse/mugle/shared/model/InvalidRatingException.java (+4/-1)
src/au/edu/unimelb/csse/mugle/shared/model/KeyValuePair.java (+4/-4)
src/au/edu/unimelb/csse/mugle/shared/model/PromotedGame.java (+2/-2)
src/au/edu/unimelb/csse/mugle/shared/model/User.java (+16/-6)
src/au/edu/unimelb/csse/mugle/shared/model/UserAchievement.java (+2/-8)
src/au/edu/unimelb/csse/mugle/shared/model/UserGameProfile.java (+5/-5)
src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/AchievementNotExists.java (+40/-0)
src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/DevTeamExists.java (+5/-1)
src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/DevTeamNotExists.java (+5/-1)
src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameExists.java (+5/-1)
src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameNotExists.java (+5/-1)
src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameVersionExists.java (+5/-1)
src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameVersionNotExists.java (+5/-1)
src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/PromotedGameExists.java (+5/-1)
src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/PromotedGameNotExists.java (+5/-1)
src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/UserExists.java (+5/-1)
src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/UserGameProfileNotExists.java (+42/-0)
src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/UserNotExists.java (+6/-2)
src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/UserPrivilegeException.java (+5/-1)
war/WEB-INF/web.xml (+43/-2)
To merge this branch: bzr merge lp:~mugle-dev/mugle/dev-api
Reviewer Review Type Date Requested Status
Matt Giuca Approve
Review via email: mp+57993@code.launchpad.net

Description of the change

Proposing to merge with the trunk since all the service calls are set up. Prageeth and I have decided to make a new branch to work on the UI and platform stuff in regards to the dev-api

To post a comment you must log in.
lp:~mugle-dev/mugle/dev-api updated
142. By Scott Ritchie

Added the mime-type and BlobKey fields to the GameFile so that games
can be stored in the blobstore

143. By Scott Ritchie

Noticed error in the datastore getters in that the queries were still
using the shared.model classes as parameters. This has now been fixed

Revision history for this message
Matt Giuca (mgiuca) wrote :

I'm not sure why this branch adds new UI capabilities. What has that got to do with the developer API?

Anyway, it looks good (from perusing the diff). Were you waiting for me to do a proper review?

Revision history for this message
Matt Giuca (mgiuca) wrote :

OK, looks good to me. Go ahead and merge it.

It seems to do a lot of stuff outside of the dev-api mandate (moving classes around, adding UI capabilities). Try to keep things unrelated to the branch in trunk or a separate branch. But it doesn't matter now (for this branch), since it's done.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'doc/dev/api.rst'
--- doc/dev/api.rst 1970-01-01 00:00:00 +0000
+++ doc/dev/api.rst 2011-04-16 12:23:28 +0000
@@ -0,0 +1,36 @@
1.. Melbourne University Game-based Learning Environment
2 Copyright (C) 2011 The University of Melbourne
3
4.. This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9.. This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14.. You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17.. _ref-dev-api:
18
19Developer API
20=============
21
22MUGLE provides a small, simple API which is available to games for
23communicating with the server. This allows limited access to the MUGLE
24database, for both reading and writing information about the current user's
25profile associated with this game.
26
27Each user has a "profile" with each game (the "user-game profile"). This
28profile associates several pieces of information with the user:
29
30* The user's highest score associated with this game.
31* The badges that the user has unlocked.
32* An arbitrary key-value mapping (unique to each user), allowing string keys
33 to be associated with arbitrary object values.
34
35All of the APIs available to games developers are available in the package
36``au.edu.unimelb.csse.mugle.client.api``.
037
=== modified file 'doc/dev/index.rst'
--- doc/dev/index.rst 2011-03-11 01:15:21 +0000
+++ doc/dev/index.rst 2011-04-16 12:23:28 +0000
@@ -28,3 +28,5 @@
2828
29.. toctree::29.. toctree::
30 :maxdepth: 230 :maxdepth: 2
31
32 api.rst
3133
=== added file 'doc/platform/datastore-access.rst'
--- doc/platform/datastore-access.rst 1970-01-01 00:00:00 +0000
+++ doc/platform/datastore-access.rst 2011-04-16 12:23:28 +0000
@@ -0,0 +1,80 @@
1.. Melbourne University Game-based Learning Environment
2 Copyright (C) 2011 The University of Melbourne
3
4.. This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9.. This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14.. You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17Accessing the Datastore
18=======================
19
20To access objects in the datastore, a set of classes called *Getters* have
21been provided in the package au.edu.unimelb.csse.mugle.server.model, each
22corresponding to a class in the au.edu.unimelb.csse.mugle.server.model package.
23This set of classes acts as an interface to the datastore, allowing developers
24to get Objects from the datastore based on their name, primary key etc.
25These are then used to pass information over to the client;
26 - By passing specific information in the class over when called in the
27 developer API services
28 - By wrapping the object using the `Datastore wrappers
29 <data-wrappers.html>`_ before passing them back to the client
30
31
32A variety of methods have been provided for each Getter - allowing you to
33retrieve an object by its Primary Key, its name, by relations it belongs to
34(for example the UserGameProfile by the current user and the game they're
35playing).
36
37There are two types of methods in each *Getter*, ones which return the object
38as read only, and ones which return the object and leave it open for editing.
39In cases where you want to update the object or call other datastore objects
40linked to it, you'll need to handle the PersistenceManager yourself; any
41changes made to an object must be made BEFORE the PersistenceManager is closed
42for the datastore to be updated with these new changes. Similarly if you need
43to access an object in the datastore from the object you've currently
44retrieved, this needs to be done before the PersistenceManager is closed.
45
46Example of updating the email of a User
47+++++++++++++++++++++++++++++++++++++++
48
49::
50
51 public void UpdateEmail(String newEmail) {
52 UserGetter u = new UserGetter();
53 UserData user = null;
54 PersistenceManager pm = PMF.getManager();
55 try {
56 user = u.getCurrentUser();
57 // Any changes must be made before closing the PersistenceManager
58 user.setEmail(newEmail);
59 } finally {
60 pm.close();
61 }
62 }
63
64Get all the Games a DevTeam has produced
65++++++++++++++++++++++++++++++++++++++++++++++++
66
67::
68
69 public Set<GameData> getGame(String devTeamName) {
70 DevTeamGetter d = new DevTeamGetter();
71 DevTeamData devTeam = null;
72 PersistenceManager pm = PMF.getManager();
73 try {
74 devTeamData = d.getDevTeam(devTeamName);
75 return devTeam.getGames();
76 } finally {
77 pm.close();
78 }
79 }
80
081
=== modified file 'doc/platform/index.rst'
--- doc/platform/index.rst 2011-03-11 01:50:22 +0000
+++ doc/platform/index.rst 2011-04-16 12:23:28 +0000
@@ -31,3 +31,4 @@
31 :maxdepth: 231 :maxdepth: 2
3232
33 data-wrappers.rst33 data-wrappers.rst
34 datastore-access.rst
3435
=== modified file 'src/au/edu/unimelb/csse/mugle/client/LoginInfo.java'
--- src/au/edu/unimelb/csse/mugle/client/LoginInfo.java 2011-03-06 10:21:39 +0000
+++ src/au/edu/unimelb/csse/mugle/client/LoginInfo.java 2011-04-16 12:23:28 +0000
@@ -27,6 +27,7 @@
27 private String logoutUrl;27 private String logoutUrl;
28 private String emailAddress;28 private String emailAddress;
29 private String nickname;29 private String nickname;
30 private String UserID; //unique ID provided by google
3031
31 public boolean isLoggedIn() {32 public boolean isLoggedIn() {
32 return loggedIn;33 return loggedIn;
@@ -67,4 +68,12 @@
67 public void setNickname(String nickname) {68 public void setNickname(String nickname) {
68 this.nickname = nickname;69 this.nickname = nickname;
69 }70 }
71
72public void setUserID(String userID) {
73 UserID = userID;
74}
75
76public String getUserID() {
77 return UserID;
78}
70}79}
7180
=== added directory 'src/au/edu/unimelb/csse/mugle/client/api'
=== added file 'src/au/edu/unimelb/csse/mugle/client/api/BadgeService.java'
--- src/au/edu/unimelb/csse/mugle/client/api/BadgeService.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/client/api/BadgeService.java 2011-04-16 12:23:28 +0000
@@ -0,0 +1,101 @@
1/* Melbourne University Game-based Learning Environment
2 * Copyright (C) 2011 The University of Melbourne
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published
6 * by the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18package au.edu.unimelb.csse.mugle.client.api;
19
20import com.google.gwt.user.client.rpc.RemoteService;
21import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
22
23import au.edu.unimelb.csse.mugle.shared.api.Badge;
24import au.edu.unimelb.csse.mugle.shared.api.BadgeError;
25import au.edu.unimelb.csse.mugle.shared.api.GameTokenError;
26
27/**
28 * Developer API for accessing the badges (achievements) system.
29 * This allows each game to award the user with badges, as well as update the
30 * progress of badges.
31 */
32@RemoteServiceRelativePath("api-badge")
33public interface BadgeService extends RemoteService
34{
35 /** Get a list of badge names for this game.
36 * @param gameToken The secret token for the current game.
37 * @return List of strings corresponding to the 'name' field of each
38 * badge in the current game.
39 */
40 public String[] getBadgeNames(String gameToken)
41 throws GameTokenError;
42
43 /** Get the static (user-independent) information about a badge for the
44 * current game.
45 * @param gameToken The secret token for the current game.
46 * @param name The name of the badge.
47 * @return Information about that badge.
48 * @throws BadgeError If no badge by that name.
49 */
50 public Badge getBadgeInfo(String gameToken, String name)
51 throws GameTokenError, BadgeError;
52
53 /** Sets the Badge to the "achieved" state.
54 * @param gameToken The secret token for the current game.
55 * @param name The name of the badge
56 * @throws BadgeError If no badge by that name.
57 */
58 public void setAchieved(String gameToken, String name)
59 throws GameTokenError, BadgeError;
60
61 /** Increments the progress of the badge by the given amount.
62 * If the progress reaches the maximum for this badge, sets the badge to
63 * achieved. The progress is capped at the badge maximum.
64 * @param gameToken The secret token for the current game.
65 * @param name The name of the badge
66 * @param amount The amount to increment the badge by. Must not be
67 * negative.
68 * @return true if the badge was achieved as a result.
69 * @throws BadgeError If no badge by that name.
70 */
71 public boolean incrementProgress(String gameToken, String name,
72 int amount) throws GameTokenError, BadgeError;
73
74 /** Increments the progress of the badge by 1.
75 * @param gameToken The secret token for the current game.
76 * @param name The name of the badge
77 * @return true if the badge was achieved as a result.
78 * @throws BadgeError If no badge by that name.
79 */
80 public boolean incrementProgress(String gameToken, String name)
81 throws GameTokenError, BadgeError;
82
83 /** Checks whether the badge has been achieved by the player.
84 * @param gameToken The secret token for the current game.
85 * @param name The name of the badge
86 * @return true if achieved, false otherwise
87 * @throws BadgeError If no badge by that name.
88 */
89 public boolean isAchieved(String gameToken, String name)
90 throws GameTokenError, BadgeError;
91
92 /** Returns the progress of the current badge.
93 * Use getBadgeInfo to retrieve the maximum progress for the badge.
94 * @param gameToken The secret token for the current game.
95 * @param name The name of the badge
96 * @return The progress of the badge
97 * @throws BadgeError If no badge by that name.
98 */
99 public int getProgress(String gameToken, String name)
100 throws GameTokenError, BadgeError;
101}
0102
=== added file 'src/au/edu/unimelb/csse/mugle/client/api/BadgeServiceAsync.java'
--- src/au/edu/unimelb/csse/mugle/client/api/BadgeServiceAsync.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/client/api/BadgeServiceAsync.java 2011-04-16 12:23:28 +0000
@@ -0,0 +1,102 @@
1/* Melbourne University Game-based Learning Environment
2 * Copyright (C) 2011 The University of Melbourne
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published
6 * by the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18package au.edu.unimelb.csse.mugle.client.api;
19
20import com.google.gwt.user.client.rpc.AsyncCallback;
21
22import au.edu.unimelb.csse.mugle.shared.api.Badge;
23
24/**
25 * Developer async API for accessing the badges (achievements) system.
26 * This allows each game to award the user with badges, as well as update the
27 * progress of badges.
28 */
29public interface BadgeServiceAsync
30{
31 /** Get a list of badge names for this game.
32 * @param gameToken The secret token for the current game.
33 * @param callback Called once the operation finishes. On success, passes
34 * a list of strings corresponding to the 'name' field of each badge in
35 * the current game.
36 */
37 void getBadgeNames(String gameToken, AsyncCallback<String[]> callback);
38
39 /** Get the static (user-independent) information about a badge for the
40 * current game.
41 * @param gameToken The secret token for the current game.
42 * @param name The name of the badge.
43 * @param callback Called once the operation finishes. On success, passes
44 * information about that badge. Fails (BadgeError) if no badge by that
45 * name.
46 */
47 void getBadgeInfo(String gameToken, String name,
48 AsyncCallback<Badge> callback);
49
50 /** Sets the Badge to the "achieved" state.
51 * @param gameToken The secret token for the current game.
52 * @param name The name of the badge
53 * @param callback Called once the operation finishes. Fails (BadgeError)
54 * if no badge by that name.
55 */
56 void setAchieved(String gameToken, String name,
57 AsyncCallback<Void> callback);
58
59 /** Increments the progress of the badge by the given amount.
60 * If the progress reaches the maximum for this badge, sets the badge to
61 * achieved. The progress is capped at the badge maximum.
62 * @param gameToken The secret token for the current game.
63 * @param name The name of the badge
64 * @param amount The amount to increment the badge by. Must not be
65 * negative.
66 * @param callback Called once the operation finishes. On success, passes
67 * true if the badge was achieved as a result. Fails (BadgeError) if no
68 * badge by that name.
69 */
70 void incrementProgress(String gameToken, String name, int amount,
71 AsyncCallback<Boolean> callback);
72
73 /** Increments the progress of the badge by 1.
74 * @param gameToken The secret token for the current game.
75 * @param name The name of the badge
76 * @param callback Called once the operation finishes. On success, passes
77 * true if the badge was achieved as a result. Fails (BadgeError) if no
78 * badge by that name.
79 */
80 void incrementProgress(String gameToken, String name,
81 AsyncCallback<Boolean> callback);
82
83 /** Checks whether the badge has been achieved by the player.
84 * @param gameToken The secret token for the current game.
85 * @param name The name of the badge
86 * @param callback Called once the operation finishes. On success, passes
87 * true if the badge is achieved. Fails (BadgeError) if no badge by that
88 * name.
89 */
90 void isAchieved(String gameToken, String name,
91 AsyncCallback<Boolean> callback);
92
93 /** Returns the progress of the current badge.
94 * Use getBadgeInfo to retrieve the maximum progress for the badge.
95 * @param gameToken The secret token for the current game.
96 * @param name The name of the badge
97 * @param callback Called once the operation finishes. On success, passes
98 * the progress of the badge. Fails (BadgeError) if no badge by that name.
99 */
100 void getProgress(String gameToken, String name,
101 AsyncCallback<Integer> callback);
102}
0103
=== added file 'src/au/edu/unimelb/csse/mugle/client/api/HighscoreService.java'
--- src/au/edu/unimelb/csse/mugle/client/api/HighscoreService.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/client/api/HighscoreService.java 2011-04-16 12:23:28 +0000
@@ -0,0 +1,46 @@
1/* Melbourne University Game-based Learning Environment
2 * Copyright (C) 2011 The University of Melbourne
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published
6 * by the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18package au.edu.unimelb.csse.mugle.client.api;
19
20import au.edu.unimelb.csse.mugle.shared.api.GameTokenError;
21
22import com.google.gwt.user.client.rpc.RemoteService;
23import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
24
25/**
26 * Developer API for accessing the current user's high-score.
27 * This allows the game to save the user's highest score.
28 */
29@RemoteServiceRelativePath("api-highscore")
30public interface HighscoreService extends RemoteService
31{
32 /** Saves the score for the current player. If this is better than the
33 * player's current high score, sets the new high score. Otherwise, does
34 * nothing.
35 * @param gameToken The secret token for the current game.
36 * @param score The player's score.
37 */
38 public void saveScore(String gameToken, int score)
39 throws GameTokenError;
40
41 /** Gets the highest score of the current player.
42 * @param gameToken The secret token for the current game.
43 * @return The player's highest score.
44 */
45 public int getHighScore(String gameToken) throws GameTokenError;
46}
047
=== added file 'src/au/edu/unimelb/csse/mugle/client/api/HighscoreServiceAsync.java'
--- src/au/edu/unimelb/csse/mugle/client/api/HighscoreServiceAsync.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/client/api/HighscoreServiceAsync.java 2011-04-16 12:23:28 +0000
@@ -0,0 +1,44 @@
1/* Melbourne University Game-based Learning Environment
2 * Copyright (C) 2011 The University of Melbourne
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published
6 * by the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18package au.edu.unimelb.csse.mugle.client.api;
19
20import com.google.gwt.user.client.rpc.AsyncCallback;
21
22/**
23 * Developer async API for accessing the current user's high-score.
24 * This allows the game to save the user's highest score.
25 */
26public interface HighscoreServiceAsync
27{
28 /** Saves the score for the current player. If this is better than the
29 * player's current high score, sets the new high score. Otherwise, does
30 * nothing.
31 * @param gameToken The secret token for the current game.
32 * @param score The player's score.
33 * @param callback Called once the operation finishes.
34 */
35 void saveScore(String gameToken, int score,
36 AsyncCallback<Void> callback);
37
38 /** Gets the highest score of the current player.
39 * @param gameToken The secret token for the current game.
40 * @param callback Called once the operation finishes. On success, passes
41 * the player's highest score.
42 */
43 void getHighScore(String gameToken, AsyncCallback<Integer> callback);
44}
045
=== added file 'src/au/edu/unimelb/csse/mugle/client/api/KeyValueService.java'
--- src/au/edu/unimelb/csse/mugle/client/api/KeyValueService.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/client/api/KeyValueService.java 2011-04-16 12:23:28 +0000
@@ -0,0 +1,63 @@
1/* Melbourne University Game-based Learning Environment
2 * Copyright (C) 2011 The University of Melbourne
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published
6 * by the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18package au.edu.unimelb.csse.mugle.client.api;
19
20import java.io.Serializable;
21
22import com.google.gwt.user.client.rpc.RemoteService;
23import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
24
25import au.edu.unimelb.csse.mugle.shared.api.GameTokenError;
26import au.edu.unimelb.csse.mugle.shared.api.KeyError;
27
28/**
29 * Developer API for accessing the key/value store.
30 * This allows each game to associate arbitrary data with string keys,
31 * independently for each user.
32 */
33@RemoteServiceRelativePath("api-keyvalue")
34public interface KeyValueService extends RemoteService
35{
36 /** Store an object in the key-value store.
37 * The value will be specific to the current user, and will only be able
38 * to be retrieved by the same user.
39 * @param gameToken The secret token for the current game.
40 * @param key The key to associate the object with.
41 * @param value The object to store.
42 */
43 public void put(String gameToken, String key, Serializable value)
44 throws GameTokenError;
45
46 /** Retrieve an object from the key-value store.
47 * The value will be the one stored by the current user.
48 * @param gameToken The secret token for the current game.
49 * @param key The key the object is associated with.
50 * @return The object associated with the key.
51 * @throws KeyError If no object is associated with that key.
52 */
53 public Serializable get(String gameToken, String key)
54 throws GameTokenError, KeyError;
55
56 /** Test whether a key has an associated object for the current user.
57 * @param gameToken The secret token for the current game.
58 * @param key The key the object is associated with.
59 * @return True if a value is associated with the key.
60 */
61 public boolean containsKey(String gameToken, String key)
62 throws GameTokenError;
63}
064
=== added file 'src/au/edu/unimelb/csse/mugle/client/api/KeyValueServiceAsync.java'
--- src/au/edu/unimelb/csse/mugle/client/api/KeyValueServiceAsync.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/client/api/KeyValueServiceAsync.java 2011-04-16 12:23:28 +0000
@@ -0,0 +1,61 @@
1/* Melbourne University Game-based Learning Environment
2 * Copyright (C) 2011 The University of Melbourne
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published
6 * by the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18package au.edu.unimelb.csse.mugle.client.api;
19
20import java.io.Serializable;
21
22import com.google.gwt.user.client.rpc.AsyncCallback;
23
24/**
25 * Developer async API for accessing the key/value store.
26 * This allows each game to associate arbitrary data with string keys,
27 * independently for each user.
28 */
29public interface KeyValueServiceAsync
30{
31 /** Store an object in the key-value store.
32 * The value will be specific to the current user, and will only be able
33 * to be retrieved by the same user.
34 * @param gameToken The secret token for the current game.
35 * @param key The key to associate the object with.
36 * @param value The object to store.
37 * @param callback Called once the operation finishes.
38 */
39 public void put(String gameToken, String key, Serializable value,
40 AsyncCallback<Void> callback);
41
42 /** Retrieve an object from the key-value store.
43 * The value will be the one stored by the current user.
44 * @param gameToken The secret token for the current game.
45 * @param key The key the object is associated with.
46 * @param callback Called once the operation finishes. On success, passes
47 * the object associated with the key. Fails (KeyError) if no object is
48 * associated with that key.
49 */
50 public void get(String gameToken, String key,
51 AsyncCallback<Serializable> callback);
52
53 /** Test whether a key has an associated object for the current user.
54 * @param gameToken The secret token for the current game.
55 * @param key The key the object is associated with.
56 * @param callback Called once the operation finishes. On success, passes
57 * true if a value is associated with the key.
58 */
59 public void containsKey(String gameToken, String key,
60 AsyncCallback<Boolean> callback);
61}
062
=== added file 'src/au/edu/unimelb/csse/mugle/client/api/Services.java'
--- src/au/edu/unimelb/csse/mugle/client/api/Services.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/client/api/Services.java 2011-04-16 12:23:28 +0000
@@ -0,0 +1,50 @@
1/* Melbourne University Game-based Learning Environment
2 * Copyright (C) 2011 The University of Melbourne
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published
6 * by the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18package au.edu.unimelb.csse.mugle.client.api;
19
20import com.google.gwt.core.client.GWT;
21import com.google.gwt.user.client.rpc.ServiceDefTarget;
22
23/** Provides access to pre-initialised instances of all the asynchronous
24 * services offered by MUGLE.
25 */
26public class Services
27{
28 /** An instance of the asynchronous user service. */
29 public static final UserServiceAsync user =
30 GWT.create(UserService.class);
31 /** An instance of the asynchronous key-value service. */
32 public static final KeyValueServiceAsync keyvalue =
33 GWT.create(KeyValueService.class);
34 /** An instance of the asynchronous badge service. */
35 public static final BadgeServiceAsync badges =
36 GWT.create(BadgeService.class);
37 /** An instance of the asynchronous high score service. */
38 public static final HighscoreServiceAsync highscore =
39 GWT.create(HighscoreService.class);
40
41 static
42 {
43 ((ServiceDefTarget) badges).setServiceEntryPoint("/mugle/api-badge");
44 ((ServiceDefTarget) highscore).setServiceEntryPoint(
45 "/mugle/api-highscore");
46 ((ServiceDefTarget) keyvalue).setServiceEntryPoint(
47 "/mugle/api-keyvalue");
48 ((ServiceDefTarget) user).setServiceEntryPoint("/mugle/api-user");
49 }
50}
051
=== added file 'src/au/edu/unimelb/csse/mugle/client/api/UserService.java'
--- src/au/edu/unimelb/csse/mugle/client/api/UserService.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/client/api/UserService.java 2011-04-16 12:23:28 +0000
@@ -0,0 +1,41 @@
1/* Melbourne University Game-based Learning Environment
2 * Copyright (C) 2011 The University of Melbourne
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published
6 * by the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18package au.edu.unimelb.csse.mugle.client.api;
19
20import com.google.gwt.user.client.rpc.RemoteService;
21import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
22
23/**
24 * Developer API for accessing information about the current user.
25 */
26@RemoteServiceRelativePath("api-user")
27public interface UserService extends RemoteService
28{
29 /** Gets the the nickname of the user playing the game.
30 * This should be used whenever the user's name needs to be displayed.
31 * Note that this nickname may change, so it should not be used to
32 * permanently associate information with the user (see getUserID).
33 */
34 public String getUserNickName();
35
36 /** Gets the user ID of the user playing the game.
37 * This is guaranteed never to change for this user, so it should be used
38 * any time some permanent information needs to be associated with a user.
39 */
40 public String getUserID();
41}
042
=== added file 'src/au/edu/unimelb/csse/mugle/client/api/UserServiceAsync.java'
--- src/au/edu/unimelb/csse/mugle/client/api/UserServiceAsync.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/client/api/UserServiceAsync.java 2011-04-16 12:23:28 +0000
@@ -0,0 +1,43 @@
1/* Melbourne University Game-based Learning Environment
2 * Copyright (C) 2011 The University of Melbourne
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published
6 * by the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18package au.edu.unimelb.csse.mugle.client.api;
19
20import com.google.gwt.user.client.rpc.AsyncCallback;
21
22/**
23 * Developer async API for accessing information about the current user.
24 */
25public interface UserServiceAsync
26{
27 /** Gets the the nickname of the user playing the game.
28 * This should be used whenever the user's name needs to be displayed.
29 * Note that this nickname may change, so it should not be used to
30 * permanently associate information with the user (see getUserID).
31 * @param callback Called once the operation finishes. On success, passes
32 * the nickname.
33 */
34 void getUserNickName(AsyncCallback<String> callback);
35
36 /** Gets the user ID of the user playing the game.
37 * This is guaranteed never to change for this user, so it should be used
38 * any time some permanent information needs to be associated with a user.
39 * @param callback Called once the operation finishes. On success, passes
40 * the user ID.
41 */
42 void getUserID(AsyncCallback<String> callback);
43}
044
=== added directory 'src/au/edu/unimelb/csse/mugle/client/ui'
=== added file 'src/au/edu/unimelb/csse/mugle/client/ui/MugleUiBuilder.java'
--- src/au/edu/unimelb/csse/mugle/client/ui/MugleUiBuilder.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/client/ui/MugleUiBuilder.java 2011-04-16 12:23:28 +0000
@@ -0,0 +1,144 @@
1package au.edu.unimelb.csse.mugle.client.ui;
2
3import java.util.Collection;
4import java.util.Iterator;
5
6import com.google.gwt.event.dom.client.ClickHandler;
7import com.google.gwt.user.client.ui.Button;
8import com.google.gwt.user.client.ui.CellPanel;
9import com.google.gwt.user.client.ui.FlexTable;
10import com.google.gwt.user.client.ui.HorizontalPanel;
11import com.google.gwt.user.client.ui.Label;
12import com.google.gwt.user.client.ui.VerticalPanel;
13import com.google.gwt.user.client.ui.Widget;
14
15public class MugleUiBuilder {
16
17 private MugleUiBuilder() { }
18
19 public static CellPanel buildStringTable(Collection<Collection<String>> list, Collection<String> headers) {
20 return buildStringTable(list, null);
21 }
22
23 public static CellPanel buildStringTable(Collection<Collection<String>> list, Collection<String> headers, PageNav pageNav) {
24
25 // build panel
26 VerticalPanel panel = new VerticalPanel();
27
28 // build table
29
30 FlexTable table = new FlexTable();
31
32 int row = 0;
33 int col = 0;
34
35 Iterator<String> it = headers.iterator();
36 while (it.hasNext()) {
37 table.setText(row, col, it.next());
38 col++;
39 }
40 row++;
41
42 Iterator<Collection<String>> iter = list.iterator();
43 while (iter.hasNext()) {
44 Iterator<String> sit = iter.next().iterator();
45 while (sit.hasNext()) {
46 table.setText(row, col, sit.next());
47 col++;
48 }
49 // check the items per page restriction
50 if (pageNav != null && pageNav.getItemsPerPage() >= row) { break; }
51 row++;
52
53 }
54
55 // add table to panel
56 panel.add(table);
57
58 // add navigation details
59 if (pageNav != null) {
60 panel.add(getNagivationDetails(pageNav));
61 }
62
63 return panel;
64
65 }
66
67 public static CellPanel buildWidgetTable(Collection<Collection<Widget>> list, Collection<String> headers) {
68 return buildWidgetTable(list, headers, null);
69 }
70
71 public static CellPanel buildWidgetTable(Collection<Collection<Widget>> list, Collection<String> headers, PageNav pageNav) {
72
73 // build panel
74 VerticalPanel panel = new VerticalPanel();
75
76 // build table
77
78 FlexTable table = new FlexTable();
79
80 int row = 0;
81 int col = 0;
82
83 Iterator<String> it = headers.iterator();
84 while (it.hasNext()) {
85 table.setText(row, col, it.next());
86 col++;
87 }
88 row++;
89
90 Iterator<Collection<Widget>> iter = list.iterator();
91 while (iter.hasNext()) {
92 Iterator<Widget> wit = iter.next().iterator();
93 while (wit.hasNext()) {
94 table.setWidget(row, col, wit.next());
95 col++;
96 }
97 // check the items per page restriction
98 if (pageNav != null && pageNav.getItemsPerPage() >= row) { break; }
99 row++;
100 }
101
102 // add table to panel
103 panel.add(table);
104
105 // add navigation details
106 if (pageNav != null) {
107 panel.add(getNagivationDetails(pageNav));
108 }
109
110 return panel;
111
112 }
113
114 private static Widget getNagivationDetails(PageNav pageNav) {
115
116 if (pageNav == null) {
117 // TODO throw Exception or handle error
118 }
119
120 HorizontalPanel hp = new HorizontalPanel();
121 hp.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT);
122
123 addNewButtonToPanel(hp, "<<", pageNav.getFirstClicked());
124 addNewButtonToPanel(hp, "<", pageNav.getPrevClicked());
125
126 // TODO add links to pages around
127 //hp.add(new Label( String.format("%d of %d", pageNav.getCurrPage(), pageNav.getMaxPages()) ));
128 hp.add(new Label( String.valueOf(pageNav.getCurrPage()) ));
129
130 addNewButtonToPanel(hp, ">", pageNav.getNextClicked());
131 addNewButtonToPanel(hp, ">>", pageNav.getLastClicked());
132
133 return hp;
134
135 }
136
137 private static void addNewButtonToPanel(CellPanel panel, String text, ClickHandler handler) {
138 Button b = new Button();
139 b.setText(text);
140 if (handler != null) { b.addClickHandler(handler); }
141 panel.add(b);
142 }
143
144}
0145
=== added file 'src/au/edu/unimelb/csse/mugle/client/ui/PageNav.java'
--- src/au/edu/unimelb/csse/mugle/client/ui/PageNav.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/client/ui/PageNav.java 2011-04-16 12:23:28 +0000
@@ -0,0 +1,78 @@
1package au.edu.unimelb.csse.mugle.client.ui;
2
3import com.google.gwt.event.dom.client.ClickHandler;
4
5public class PageNav {
6
7 private int currPage = 0;
8 private int maxPages = 0;
9 private int itemsPerPage = 0;
10
11 private ClickHandler firstClicked = null;
12 private ClickHandler prevClicked = null;
13 private ClickHandler nextClicked = null;
14 private ClickHandler lastClicked = null;
15
16 public PageNav(int currPage, int maxPages, int itemsPerPage) {
17 this.currPage = currPage;
18 this.maxPages = maxPages;
19 this.itemsPerPage = itemsPerPage;
20 }
21
22 public int getCurrPage() {
23 return this.currPage;
24 }
25
26 public void setCurrPage(int currPage) {
27 this.currPage = currPage;
28 }
29
30 public int getMaxPages() {
31 return this.maxPages;
32 }
33
34 public void setMaxPages(int maxPages) {
35 this.maxPages = maxPages;
36 }
37
38 public int getItemsPerPage() {
39 return this.itemsPerPage;
40 }
41
42 public void setItemsPerPage(int itemsPerPage) {
43 this.itemsPerPage = itemsPerPage;
44 }
45
46 public ClickHandler getFirstClicked() {
47 return this.firstClicked;
48 }
49
50 public void setFirstClicked(ClickHandler firstClicked) {
51 this.firstClicked = firstClicked;
52 }
53
54 public ClickHandler getPrevClicked() {
55 return this.prevClicked;
56 }
57
58 public void setPrevClicked(ClickHandler prevClicked) {
59 this.prevClicked = prevClicked;
60 }
61
62 public ClickHandler getNextClicked() {
63 return this.nextClicked;
64 }
65
66 public void setNextClicked(ClickHandler nextClicked) {
67 this.nextClicked = nextClicked;
68 }
69
70 public ClickHandler getLastClicked() {
71 return this.lastClicked;
72 }
73
74 public void setLastClicked(ClickHandler lastClicked) {
75 this.lastClicked = lastClicked;
76 }
77
78}
079
=== modified file 'src/au/edu/unimelb/csse/mugle/server/DataTestServiceImpl.java'
--- src/au/edu/unimelb/csse/mugle/server/DataTestServiceImpl.java 2011-03-30 15:46:59 +0000
+++ src/au/edu/unimelb/csse/mugle/server/DataTestServiceImpl.java 2011-04-16 12:23:28 +0000
@@ -22,7 +22,6 @@
2222
23import au.edu.unimelb.csse.mugle.client.*;23import au.edu.unimelb.csse.mugle.client.*;
24import au.edu.unimelb.csse.mugle.server.model.*;24import au.edu.unimelb.csse.mugle.server.model.*;
25import au.edu.unimelb.csse.mugle.server.platform.*;
26import au.edu.unimelb.csse.mugle.shared.model.*;25import au.edu.unimelb.csse.mugle.shared.model.*;
2726
28@SuppressWarnings("serial")27@SuppressWarnings("serial")
2928
=== modified file 'src/au/edu/unimelb/csse/mugle/server/LoginServiceImpl.java'
--- src/au/edu/unimelb/csse/mugle/server/LoginServiceImpl.java 2011-03-06 10:23:58 +0000
+++ src/au/edu/unimelb/csse/mugle/server/LoginServiceImpl.java 2011-04-16 12:23:28 +0000
@@ -36,6 +36,7 @@
36 loginInfo.setLoggedIn(true);36 loginInfo.setLoggedIn(true);
37 loginInfo.setEmailAddress(user.getEmail());37 loginInfo.setEmailAddress(user.getEmail());
38 loginInfo.setNickname(user.getNickname());38 loginInfo.setNickname(user.getNickname());
39 loginInfo.setUserID(user.getUserId());
39 loginInfo.setLogoutUrl(userService.createLogoutURL(requestUri));40 loginInfo.setLogoutUrl(userService.createLogoutURL(requestUri));
40 } else {41 } else {
41 loginInfo.setLoggedIn(false);42 loginInfo.setLoggedIn(false);
@@ -43,5 +44,25 @@
43 }44 }
44 return loginInfo;45 return loginInfo;
45 }46 }
47
48 /* For server side purposes only,
49 * Gets the currently logged in user as above, but without the
50 * Host's url. Used in most server side service implementations
51 */
52 public LoginInfo getCurrentUser() {
53 UserService userService = UserServiceFactory.getUserService();
54 User user = userService.getCurrentUser();
55 LoginInfo loginInfo = new LoginInfo();
56
57 if (user != null) {
58 loginInfo.setLoggedIn(true);
59 loginInfo.setEmailAddress(user.getEmail());
60 loginInfo.setNickname(user.getNickname());
61 loginInfo.setUserID(user.getUserId());
62 } else {
63 loginInfo.setLoggedIn(false);
64 }
65 return loginInfo;
66 }
4667
47}68}
4869
=== renamed file 'src/au/edu/unimelb/csse/mugle/server/platform/PMF.java' => 'src/au/edu/unimelb/csse/mugle/server/PMF.java'
--- src/au/edu/unimelb/csse/mugle/server/platform/PMF.java 2011-03-06 10:18:13 +0000
+++ src/au/edu/unimelb/csse/mugle/server/PMF.java 2011-04-16 12:23:28 +0000
@@ -15,7 +15,7 @@
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */16 */
1717
18package au.edu.unimelb.csse.mugle.server.platform;18package au.edu.unimelb.csse.mugle.server;
1919
20import javax.jdo.JDOHelper;20import javax.jdo.JDOHelper;
21import javax.jdo.PersistenceManager;21import javax.jdo.PersistenceManager;
2222
=== added directory 'src/au/edu/unimelb/csse/mugle/server/api'
=== added file 'src/au/edu/unimelb/csse/mugle/server/api/BadgeServiceImpl.java'
--- src/au/edu/unimelb/csse/mugle/server/api/BadgeServiceImpl.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/server/api/BadgeServiceImpl.java 2011-04-16 12:23:28 +0000
@@ -0,0 +1,149 @@
1/* Melbourne University Game-based Learning Environment
2 * Copyright (C) 2011 The University of Melbourne
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18package au.edu.unimelb.csse.mugle.server.api;
19
20import java.util.ArrayList;
21
22import au.edu.unimelb.csse.mugle.client.api.BadgeService;
23import au.edu.unimelb.csse.mugle.server.PMF;
24import au.edu.unimelb.csse.mugle.server.model.AchievementData;
25import au.edu.unimelb.csse.mugle.server.model.AchievementGetter;
26import au.edu.unimelb.csse.mugle.server.model.GameData;
27import au.edu.unimelb.csse.mugle.server.model.GameGetter;
28import au.edu.unimelb.csse.mugle.server.model.UserAchievementData;
29import au.edu.unimelb.csse.mugle.server.model.UserAchievementGetter;
30import au.edu.unimelb.csse.mugle.shared.api.Badge;
31import au.edu.unimelb.csse.mugle.shared.api.BadgeError;
32import au.edu.unimelb.csse.mugle.shared.api.GameTokenError;
33
34import au.edu.unimelb.csse.mugle.shared.platform.exceptions.*;
35
36import com.google.gwt.user.server.rpc.RemoteServiceServlet;
37
38import javax.jdo.PersistenceManager;
39
40
41/**
42 * The server side implementation of KeyValueService.
43 */
44@SuppressWarnings("serial")
45public class BadgeServiceImpl extends RemoteServiceServlet
46 implements BadgeService
47{
48 private UserAchievementData getUserAchievement(String gameToken, String name) throws GameTokenError, BadgeError {
49 PersistenceManager pm = PMF.getManager();
50 try {
51 return this.getUserAchievement(pm, gameToken, name);
52 } finally {
53 pm.close();
54 }
55 }
56
57 private UserAchievementData getUserAchievement(PersistenceManager pm, String gameToken, String name) throws GameTokenError, BadgeError {
58 UserAchievementGetter u = new UserAchievementGetter();
59 try {
60 return u.getUserAchievement(pm, name, gameToken);
61 } catch (UserNotExists e) {
62 throw new Error(e);
63 } catch (AchievementNotExists e) {
64 throw new BadgeError(e.getMessage());
65 }
66 }
67
68 @Override
69 public String[] getBadgeNames(String gameToken) throws GameTokenError {
70 ArrayList<String> toReturn = new ArrayList<String>();
71 GameGetter g = new GameGetter();
72 GameData curGame = null;
73
74 curGame = g.getCurrentGame(gameToken);
75
76 for (AchievementData a: curGame.getAchievements()) {
77 toReturn.add(a.getName());
78 }
79 return (String[]) toReturn.toArray();
80 }
81
82 @Override
83 public Badge getBadgeInfo(String gameToken, String name)
84 throws GameTokenError, BadgeError {
85 PersistenceManager pm = PMF.getManager();
86 AchievementData a;
87 try {
88 AchievementGetter ag = new AchievementGetter();
89 a = ag.getAchievement(pm, name, gameToken);;
90 } catch (AchievementNotExists e) {
91 throw new BadgeError(e.getMessage());
92 } finally {
93 pm.close();
94 }
95 // XXX The badge API requires both a short name and a display name
96 // Currently use the same name for both; requires changes to
97 // Achievement class.
98 return new Badge(a.getName(), a.getName(), a.getDescription(),
99 a.getMaxProgress());
100 }
101
102 @Override
103 public boolean isAchieved(String gameToken, String name) throws GameTokenError, BadgeError {
104 return this.getUserAchievement(gameToken, name).getAchieved();
105 }
106
107 @Override
108 public int getProgress(String gameToken, String name) throws GameTokenError, BadgeError {
109 return this.getUserAchievement(gameToken, name).getProgress();
110 }
111
112 @Override
113 public boolean incrementProgress(String gameToken, String name, int amount) throws GameTokenError, BadgeError {
114 PersistenceManager pm = PMF.getManager();
115
116 if (amount < 0)
117 throw new BadgeError("incrementProgress called with negative amount");
118
119 try {
120 UserAchievementData ua = this.getUserAchievement(pm, gameToken, name);
121 if (ua.getAchievement().getMaxProgress() == 0) {
122 throw new BadgeError("incrementProgress called on non-progress badge " + name);
123 }
124 return ua.addProgress(amount);
125 } finally {
126 pm.close();
127 }
128 }
129
130 @Override
131 public boolean incrementProgress(String gameToken, String name) throws GameTokenError, BadgeError{
132 return incrementProgress(gameToken, name, 1);
133 }
134
135 @Override
136 public void setAchieved(String gameToken, String name) throws GameTokenError, BadgeError {
137 PersistenceManager pm = PMF.getManager();
138
139 try {
140 UserAchievementData ua = this.getUserAchievement(pm, gameToken, name);
141 ua.setAchieved(true);
142 // also need to set the progress
143 ua.setProgress(ua.getAchievement().getMaxProgress());
144 } finally {
145 pm.close();
146 }
147 }
148
149}
0150
=== added file 'src/au/edu/unimelb/csse/mugle/server/api/HighscoreServiceImpl.java'
--- src/au/edu/unimelb/csse/mugle/server/api/HighscoreServiceImpl.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/server/api/HighscoreServiceImpl.java 2011-04-16 12:23:28 +0000
@@ -0,0 +1,65 @@
1/* Melbourne University Game-based Learning Environment
2 * Copyright (C) 2011 The University of Melbourne
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18package au.edu.unimelb.csse.mugle.server.api;
19
20import au.edu.unimelb.csse.mugle.client.api.HighscoreService;
21import au.edu.unimelb.csse.mugle.server.PMF;
22import au.edu.unimelb.csse.mugle.server.model.UserGameProfileGetter;
23import au.edu.unimelb.csse.mugle.shared.api.GameTokenError;
24import au.edu.unimelb.csse.mugle.server.model.UserGameProfileData;
25import au.edu.unimelb.csse.mugle.shared.platform.exceptions.UserNotExists;
26
27import com.google.gwt.user.server.rpc.RemoteServiceServlet;
28
29import javax.jdo.PersistenceManager;
30
31
32/**
33 * The server side implementation of KeyValueService.
34 */
35@SuppressWarnings("serial")
36public class HighscoreServiceImpl extends RemoteServiceServlet
37 implements HighscoreService
38{
39
40 public int getHighScore(String gameToken) throws GameTokenError {
41 UserGameProfileGetter u = new UserGameProfileGetter();
42 UserGameProfileData ugp;
43 try {
44 ugp = u.getCurrentUserGameProfile(gameToken);
45 } catch (UserNotExists e) {
46 throw new Error(e);
47 }
48 return ugp.getHighscore();
49 }
50
51 public void saveScore(String gameToken, int score) throws GameTokenError {
52 PersistenceManager pm = PMF.getManager();
53 UserGameProfileGetter u = new UserGameProfileGetter();
54 UserGameProfileData ugp = null;
55 try {
56 ugp = u.getCurrentUserGameProfile(pm, gameToken);
57 if (score > ugp.getHighscore())
58 ugp.setHighscore(score);
59 } catch (UserNotExists e) {
60 throw new Error(e);
61 } finally {
62 pm.close();
63 }
64 }
65}
066
=== added file 'src/au/edu/unimelb/csse/mugle/server/api/KeyValueServiceImpl.java'
--- src/au/edu/unimelb/csse/mugle/server/api/KeyValueServiceImpl.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/server/api/KeyValueServiceImpl.java 2011-04-16 12:23:28 +0000
@@ -0,0 +1,89 @@
1/* Melbourne University Game-based Learning Environment
2 * Copyright (C) 2011 The University of Melbourne
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18package au.edu.unimelb.csse.mugle.server.api;
19
20import java.io.Serializable;
21
22import au.edu.unimelb.csse.mugle.client.api.KeyValueService;
23import au.edu.unimelb.csse.mugle.server.PMF;
24import au.edu.unimelb.csse.mugle.server.model.KeyValuePairGetter;
25import au.edu.unimelb.csse.mugle.shared.api.GameTokenError;
26import au.edu.unimelb.csse.mugle.shared.api.KeyError;
27import au.edu.unimelb.csse.mugle.server.model.KeyValuePairData;
28import au.edu.unimelb.csse.mugle.shared.platform.exceptions.*;
29
30import com.google.gwt.user.server.rpc.RemoteServiceServlet;
31
32import javax.jdo.PersistenceManager;
33
34/**
35 * The server side implementation of KeyValueService.
36 */
37@SuppressWarnings("serial")
38public class KeyValueServiceImpl extends RemoteServiceServlet
39 implements KeyValueService
40{
41 public void put(String gameToken, String key, Serializable value)
42 throws GameTokenError
43 {
44 PersistenceManager pm = PMF.getManager();
45 KeyValuePairGetter k = new KeyValuePairGetter();
46 KeyValuePairData kvp = null;
47
48 try {
49 kvp = k.getKeyValuePair(pm, key, gameToken, true);
50 kvp.setValue(value);
51 } catch (UserNotExists e) {
52 throw new Error(e);
53 } catch (KeyError e) {
54 // XXX This should never happen (since we are using createIfNotFound=true)
55 throw new Error(e);
56 } finally {
57 pm.close();
58 }
59 }
60
61 public Serializable get(String gameToken, String key)
62 throws GameTokenError, KeyError
63 {
64 KeyValuePairGetter k = new KeyValuePairGetter();
65 KeyValuePairData kvp;
66 try {
67 kvp = k.getKeyValuePair(key, gameToken);
68 } catch (UserNotExists e) {
69 throw new Error(e);
70 }
71 return (Serializable) kvp.getValue();
72 }
73
74 public boolean containsKey(String gameToken, String key)
75 throws GameTokenError
76 {
77 KeyValuePairGetter k = new KeyValuePairGetter();
78 try {
79 k.getKeyValuePair(key, gameToken);
80 } catch (UserNotExists e) {
81 throw new Error(e);
82 } catch (KeyError e) {
83 return false;
84 }
85 return true;
86
87 }
88
89}
090
=== added file 'src/au/edu/unimelb/csse/mugle/server/api/UserServiceImpl.java'
--- src/au/edu/unimelb/csse/mugle/server/api/UserServiceImpl.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/server/api/UserServiceImpl.java 2011-04-16 12:23:28 +0000
@@ -0,0 +1,58 @@
1/* Melbourne University Game-based Learning Environment
2 * Copyright (C) 2011 The University of Melbourne
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18package au.edu.unimelb.csse.mugle.server.api;
19
20import au.edu.unimelb.csse.mugle.client.api.UserService;
21import au.edu.unimelb.csse.mugle.server.model.UserGetter;
22import au.edu.unimelb.csse.mugle.shared.platform.exceptions.UserNotExists;
23
24import com.google.gwt.user.server.rpc.RemoteServiceServlet;
25
26
27/**
28 * The server side implementation of KeyValueService.
29 */
30@SuppressWarnings("serial")
31public class UserServiceImpl extends RemoteServiceServlet
32 implements UserService
33{
34
35 public String getUserNickName() {
36 UserGetter u = new UserGetter();
37 try
38 {
39 return u.getCurrentUser().getUrlName();
40 }
41 catch (UserNotExists e)
42 {
43 throw new Error(e);
44 }
45 }
46
47 public String getUserID() {
48 UserGetter u = new UserGetter();
49 try
50 {
51 return u.getCurrentUser().getGoogleID();
52 }
53 catch (UserNotExists e)
54 {
55 throw new Error(e);
56 }
57 }
58}
059
=== modified file 'src/au/edu/unimelb/csse/mugle/server/model/AchievementData.java'
--- src/au/edu/unimelb/csse/mugle/server/model/AchievementData.java 2011-04-08 11:00:59 +0000
+++ src/au/edu/unimelb/csse/mugle/server/model/AchievementData.java 2011-04-16 12:23:28 +0000
@@ -47,6 +47,10 @@
47 @Persistent47 @Persistent
48 private String name;48 private String name;
4949
50 @UserLevel(privateView=Role.DEVELOPER, publicView=Role.DEVELOPER, mappedBy="displayName")
51 @Persistent
52 private String displayName;
53
50 @UserLevel(privateView=Role.DEVELOPER, publicView=Role.DEVELOPER, mappedBy="description")54 @UserLevel(privateView=Role.DEVELOPER, publicView=Role.DEVELOPER, mappedBy="description")
51 @Persistent55 @Persistent
52 private String description;56 private String description;
@@ -71,6 +75,7 @@
71 75
72 this.userAchievements = new HashSet<UserAchievementData>();76 this.userAchievements = new HashSet<UserAchievementData>();
73 this.name = null;77 this.name = null;
78 this.displayName = null;
74 this.description = null;79 this.description = null;
75 this.maxProgress = null;80 this.maxProgress = null;
76 this.game = null;81 this.game = null;
@@ -79,11 +84,12 @@
79 }84 }
80 85
81 /* Should only be added through developers interface */86 /* Should only be added through developers interface */
82 public AchievementData(String name, String description, Integer maxProgress, Game game) {87 public AchievementData(String name, String displayName, String description, Integer maxProgress, Game game) {
8388
84 this.userAchievements = new HashSet<UserAchievementData>();89 this.userAchievements = new HashSet<UserAchievementData>();
8590
86 this.name = name;91 this.name = name;
92 this.displayName = displayName;
87 this.description = description;93 this.description = description;
88 this.maxProgress = maxProgress;94 this.maxProgress = maxProgress;
89 this.game = game;95 this.game = game;
@@ -101,6 +107,10 @@
101 public String getName() {107 public String getName() {
102 return this.name;108 return this.name;
103 }109 }
110
111 public String getDisplayName() {
112 return displayName;
113 }
104114
105 public String getDescription() {115 public String getDescription() {
106 return this.description;116 return this.description;
@@ -120,23 +130,27 @@
120130
121 // Setters131 // Setters
122132
123 /* Setters are protected - in the case of wanting to change an achievement, better133 /* in the case of wanting to change an achievement, better
124 * to leave the old ID, so that users dont lose their achievements if they ever need134 * to leave the old ID, so that users dont lose their achievements if they ever need
125 * updating135 * updating
126 */136 */
127 protected void setName(String newName) {137 public void setName(String newName) {
128 this.name = newName;138 this.name = newName;
129 }139 }
140
141 public void setDisplayName(String displayName) {
142 this.displayName = displayName;
143 }
130144
131 protected void setDescription(String newDescription) {145 public void setDescription(String newDescription) {
132 this.description = newDescription;146 this.description = newDescription;
133 }147 }
134148
135 protected void setMaxProgress(Integer newProgress) {149 public void setMaxProgress(Integer newProgress) {
136 this.maxProgress = newProgress;150 this.maxProgress = newProgress;
137 }151 }
138152
139 protected void setGame(Game game) {153 public void setGame(Game game) {
140 this.game = game;154 this.game = game;
141 }155 }
142 156
143157
=== added file 'src/au/edu/unimelb/csse/mugle/server/model/AchievementGetter.java'
--- src/au/edu/unimelb/csse/mugle/server/model/AchievementGetter.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/server/model/AchievementGetter.java 2011-04-16 12:23:28 +0000
@@ -0,0 +1,109 @@
1/* Melbourne University Game-based Learning Environment
2 * Copyright (C) 2011 The University of Melbourne
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18package au.edu.unimelb.csse.mugle.server.model;
19
20import javax.jdo.PersistenceManager;
21import javax.jdo.Query;
22
23import au.edu.unimelb.csse.mugle.server.PMF;
24import au.edu.unimelb.csse.mugle.shared.api.GameTokenError;
25import au.edu.unimelb.csse.mugle.shared.platform.exceptions.AchievementNotExists;
26
27public class AchievementGetter {
28
29 /**
30 * Gets the Achievement of the current game based on its name - READ ONLY
31 * @param name Name of the achievement you're looking for
32 * @param gameToken the secret game token for the current game, provided by the client
33 * @return The requested Achievement - READ ONLY
34 * @throws GameTokenError
35 * @throws AchievementNotExists
36 */
37 public AchievementData getAchievement(String name, String gameToken)
38 throws GameTokenError, AchievementNotExists {
39 PersistenceManager pm = PMF.getManager();
40 try {
41 return getAchievement(pm, name, gameToken);
42 } finally {
43 pm.close();
44 }
45 }
46
47 /**
48 * Gets the Achievement of the current game based on its name, for editing object in datstore
49 * The PersistenceManager must be handled by the caller
50 * @param pm The Persistence Manager
51 * @param name Name of the achievement you're looking for
52 * @param gameToken the secret game token for the current game, provided by the client
53 * @return The requested Achievement
54 * @throws GameTokenError
55 * @throws AchievementNotExists
56 */
57 public AchievementData getAchievement(PersistenceManager pm, String name, String gameToken)
58 throws GameTokenError, AchievementNotExists {
59 GameGetter g = new GameGetter();
60 GameData curGame = g.getCurrentGame(pm, gameToken);
61
62 Query q = pm.newQuery(AchievementData.class, "game == g && name == n");
63 q.declareParameters("GameData g, String n");
64 AchievementData achievement = (AchievementData) q.execute(curGame, name);
65
66 if (achievement == null) {
67 throw new AchievementNotExists(curGame.getUrlName(), name);
68 }
69
70 return achievement;
71 }
72
73 /**
74 * Gets the Achievement of the current game based on its Primary Key - READ ONLY
75 * @param primaryKey the primary key of the Achievement
76 * @return The requested Achievement - READ ONLY
77 * @throws GameTokenError
78 * @throws AchievementNotExists
79 */
80 public AchievementData getAchievement(Long primaryKey)
81 throws GameTokenError, AchievementNotExists {
82 PersistenceManager pm = PMF.getManager();
83 try {
84 return getAchievement(pm, primaryKey);
85 } finally {
86 pm.close();
87 }
88 }
89
90 /**
91 * Gets the Achievement of the current game based on its Primary Key, for editing object in datstore
92 * The PersistenceManager must be handled by the caller
93 * @param pm The Persistence Manager
94 * @param primaryKey the primary key of the Achievement
95 * @return The requested Achievement
96 * @throws GameTokenError
97 * @throws AchievementNotExists
98 */
99 public AchievementData getAchievement(PersistenceManager pm, Long primaryKey)
100 throws AchievementNotExists {
101 AchievementData achievement = pm.getObjectById(AchievementData.class, primaryKey);
102
103 if (achievement == null) {
104 throw new AchievementNotExists(primaryKey);
105 }
106
107 return achievement;
108 }
109}
0110
=== added file 'src/au/edu/unimelb/csse/mugle/server/model/DevTeamGetter.java'
--- src/au/edu/unimelb/csse/mugle/server/model/DevTeamGetter.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/server/model/DevTeamGetter.java 2011-04-16 12:23:28 +0000
@@ -0,0 +1,78 @@
1package au.edu.unimelb.csse.mugle.server.model;
2
3import javax.jdo.PersistenceManager;
4import javax.jdo.Query;
5
6import au.edu.unimelb.csse.mugle.server.PMF;
7import au.edu.unimelb.csse.mugle.shared.platform.exceptions.DevTeamNotExists;
8
9public class DevTeamGetter {
10
11 /**
12 * Gets the DevTeamData by its urlName - READ ONLY
13 * @param name The name of the DevTeamData
14 * @return The DevTeamData - READ ONLY
15 * @throws DevTeamDataNotExists
16 */
17 public DevTeamData getDevTeam(String name) throws DevTeamNotExists {
18 PersistenceManager pm = PMF.getManager();
19 try {
20 return getDevTeam(pm, name);
21 } finally {
22 pm.close();
23 }
24 }
25
26 /**
27 * Gets the DevTeamData by its urlName, for editing in the datastore
28 * The Persistence Manager must be handled by the caller
29 * @param pm The PersistenceManager
30 * @param name The Name of the Dev Team
31 * @return The DevTeamData
32 * @throws DevTeamDataNotExists
33 */
34 public DevTeamData getDevTeam(PersistenceManager pm, String name) throws DevTeamNotExists {
35 DevTeamData devTeam= null;
36 Query q = pm.newQuery(DevTeamData.class, "urlName == u");
37 q.declareParameters("String u");
38 devTeam = (DevTeamData) q.execute(name);
39
40 if (devTeam == null) {
41 throw new DevTeamNotExists(name);
42 }
43
44 return devTeam;
45 }
46 /**
47 * Gets the DevTeamDataData by its primary key - READ ONLY
48 * @param primaryKey
49 * @return The DevTeamDataData - READ ONLY
50 * @throws DevTeamDataDataNotExists
51 */
52 public DevTeamData getDevTeam(Long primaryKey) throws DevTeamNotExists {
53 PersistenceManager pm = PMF.getManager();
54 try {
55 return getDevTeam(pm, primaryKey);
56 } finally {
57 pm.close();
58 }
59 }
60
61 /**
62 * Gets the DevTeamDataData by its primary key, for editing in the datastore
63 * The Persistence Manager must be handled by the caller
64 * @param pm The PersistenceManager
65 * @param primaryKey
66 * @return The DevTeamDataData
67 * @throws DevTeamDataDataNotExists
68 */
69 public DevTeamData getDevTeam(PersistenceManager pm, Long primaryKey) throws DevTeamNotExists {
70 DevTeamData devTeam = pm.getObjectById(DevTeamData.class, primaryKey);
71
72 if (devTeam == null) {
73 throw new DevTeamNotExists(primaryKey);
74 }
75
76 return devTeam;
77 }
78}
079
=== modified file 'src/au/edu/unimelb/csse/mugle/server/model/GameData.java'
--- src/au/edu/unimelb/csse/mugle/server/model/GameData.java 2011-04-08 11:00:59 +0000
+++ src/au/edu/unimelb/csse/mugle/server/model/GameData.java 2011-04-16 12:23:28 +0000
@@ -48,6 +48,10 @@
48 @Persistent48 @Persistent
49 private String urlName; //Must be unique49 private String urlName; //Must be unique
5050
51 @UserLevel(privateView=Role.DEVELOPER, publicView=Role.DEVELOPER, mappedBy="gameToken")
52 @Persistent
53 private String gameToken;
54
51 @UserLevel(privateView=Role.DEVELOPER, publicView=Role.DEVELOPER, mappedBy="userRating")55 @UserLevel(privateView=Role.DEVELOPER, publicView=Role.DEVELOPER, mappedBy="userRating")
52 @Persistent56 @Persistent
53 private Integer userRating;57 private Integer userRating;
@@ -82,6 +86,7 @@
82 this.gameVersions = new HashSet<GameVersionData>();86 this.gameVersions = new HashSet<GameVersionData>();
83 this.ugps = new HashSet<Key>();87 this.ugps = new HashSet<Key>();
84 this.achievements = new HashSet<AchievementData>();88 this.achievements = new HashSet<AchievementData>();
89 this.gameToken = null;
85 this.urlName = null;90 this.urlName = null;
86 this.userRating = null;91 this.userRating = null;
87 this.totalRatings = null;92 this.totalRatings = null;
@@ -95,7 +100,9 @@
95 this.ugps = new HashSet<Key>();100 this.ugps = new HashSet<Key>();
96 this.achievements = new HashSet<AchievementData>();101 this.achievements = new HashSet<AchievementData>();
97102
98 //TODO: check that urlName is unique103 //TODO: generate a gameToken
104 this.gameToken = null;
105 //TODO: check that urlName is unique
99 this.urlName = urlName;106 this.urlName = urlName;
100 this.userRating = 0;107 this.userRating = 0;
101 this.totalRatings = 0;108 this.totalRatings = 0;
@@ -137,6 +144,10 @@
137 public Set<Key> getUserGameProfiles() {144 public Set<Key> getUserGameProfiles() {
138 return this.ugps;145 return this.ugps;
139 }146 }
147
148 public String getGameToken() {
149 return gameToken;
150 }
140151
141152
142 // Setters153 // Setters
143154
=== modified file 'src/au/edu/unimelb/csse/mugle/server/model/GameFileData.java'
--- src/au/edu/unimelb/csse/mugle/server/model/GameFileData.java 2011-04-08 11:00:59 +0000
+++ src/au/edu/unimelb/csse/mugle/server/model/GameFileData.java 2011-04-16 12:23:28 +0000
@@ -25,6 +25,7 @@
25import javax.jdo.annotations.Persistent;25import javax.jdo.annotations.Persistent;
26import javax.jdo.annotations.PrimaryKey;26import javax.jdo.annotations.PrimaryKey;
2727
28import com.google.appengine.api.blobstore.BlobKey;
28import com.google.appengine.api.datastore.Key;29import com.google.appengine.api.datastore.Key;
2930
30import au.edu.unimelb.csse.mugle.shared.model.*;31import au.edu.unimelb.csse.mugle.shared.model.*;
@@ -47,8 +48,14 @@
47 @Persistent48 @Persistent
48 private String path; //path to the file relative to the Game URL49 private String path; //path to the file relative to the Game URL
49 50
50 // TODO: data (blob)51 @UserLevel(privateView=Role.DEVELOPER, publicView=Role.DEVELOPER, mappedBy="mimeType")
52 @Persistent
53 private String mimeType; //mime type of the file
5154
55 @UserLevel(privateView=Role.DEVELOPER, publicView=Role.DEVELOPER, useMethod=true, mappedBy="getBlobKeyString")
56 @Persistent
57 private BlobKey blobKey; //key to the actual blob
58
52 // Many-to-many59 // Many-to-many
53 @UserLevel(privateView=Role.DEVELOPER, publicView=Role.DEVELOPER, useMethod=true, mappedBy="keysToGameVersions")60 @UserLevel(privateView=Role.DEVELOPER, publicView=Role.DEVELOPER, useMethod=true, mappedBy="keysToGameVersions")
54 @Persistent61 @Persistent
@@ -58,6 +65,8 @@
58 // Constructors65 // Constructors
59 public GameFileData() {66 public GameFileData() {
60 this.versions = new HashSet<Key>();67 this.versions = new HashSet<Key>();
68 this.setMimeType(null);
69 this.setBlobKey(null);
61 this.path = null;70 this.path = null;
62 }71 }
6372
@@ -179,4 +188,24 @@
179 return this.fetchClientObjects(GameVersionData.class, this.versions);188 return this.fetchClientObjects(GameVersionData.class, this.versions);
180 }189 }
181190
191 public String getBlobKeyString() {
192 return this.blobKey.getKeyString();
193 }
194
195 public void setMimeType(String mimeType) {
196 this.mimeType = mimeType;
197 }
198
199 public String getMimeType() {
200 return mimeType;
201 }
202
203 public void setBlobKey(BlobKey blobKey) {
204 this.blobKey = blobKey;
205 }
206
207 public BlobKey getBlobKey() {
208 return blobKey;
209 }
210
182}211}
183212
=== added file 'src/au/edu/unimelb/csse/mugle/server/model/GameGetter.java'
--- src/au/edu/unimelb/csse/mugle/server/model/GameGetter.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/server/model/GameGetter.java 2011-04-16 12:23:28 +0000
@@ -0,0 +1,132 @@
1/* Melbourne University Game-based Learning Environment
2 * Copyright (C) 2011 The University of Melbourne
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18package au.edu.unimelb.csse.mugle.server.model;
19
20import javax.jdo.PersistenceManager;
21import javax.jdo.Query;
22
23import au.edu.unimelb.csse.mugle.server.PMF;
24import au.edu.unimelb.csse.mugle.shared.api.GameTokenError;
25import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameNotExists;
26
27public class GameGetter {
28 /**
29 * Gets the Game by its Primary Key - READ ONLY
30 * @param primaryKey
31 * @return the Game - read only
32 * @throws GameNotExists
33 */
34 public GameData getGame(Long primaryKey) throws GameNotExists {
35 PersistenceManager pm = PMF.getManager();
36 try {
37 return getGame(pm, primaryKey);
38 } finally {
39 pm.close();
40 }
41 }
42
43 /**
44 * Gets the Game by its Primary Key, for editing object in datstore
45 * PersistenceManager must be handled by the caller
46 * @param pm the PersistenceManager
47 * @param primaryKey
48 * @return the Game
49 * @throws GameNotExists
50 */
51 public GameData getGame(PersistenceManager pm, Long primaryKey) throws GameNotExists{
52 GameData game = pm.getObjectById(GameData.class, primaryKey);
53
54 if(game == null) {
55 throw new GameNotExists(primaryKey);
56 }
57
58 return game;
59 }
60
61 /**
62 * Gets the Game by its name - READ ONLY
63 * @param name
64 * @return the Game - read only
65 * @throws GameNotExists
66 */
67 public GameData getGame(String name) throws GameNotExists {
68 PersistenceManager pm = PMF.getManager();
69 try {
70 return getGame(pm, name);
71 } finally {
72 pm.close();
73 }
74 }
75
76 /**
77 * Gets the Game by name, for editing object in datstore
78 * PersistenceManager must be handled by the caller
79 * @param pm the PersistenceManager
80 * @param name
81 * @return the Game
82 * @throws GameNotExists
83 */
84 public GameData getGame(PersistenceManager pm, String name) throws GameNotExists{
85 GameData game = null;
86 Query q = pm.newQuery(GameData.class, "urlName == u");
87 q.declareParameters("String u");
88 game = (GameData) q.execute(name);
89
90 if(game == null) {
91 throw new GameNotExists(name);
92 }
93
94 return game;
95 }
96
97 /**
98 * Gets the Game from a provided gameToken - READ ONLY
99 * @param gameToken the secret game token for the current game, provided by the client
100 * @return the Game - read only
101 * @throws GameTokenError
102 */
103 public GameData getCurrentGame(String gameToken) throws GameTokenError {
104 PersistenceManager pm = PMF.getManager();
105 try {
106 return getCurrentGame(pm, gameToken);
107 } finally {
108 pm.close();
109 }
110 }
111
112 /**
113 * Gets the Game from a provided gameToken, for editing object in datstore
114 * PersistenceManager must be handled by the caller
115 * @param pm the PersistenceManager
116 * @param gameToken the secret game token for the current game, provided by the client
117 * @return the Game
118 * @throws GameTokenError
119 */
120 public GameData getCurrentGame(PersistenceManager pm, String gameToken) throws GameTokenError {
121 GameData curGame = null;
122 Query q = pm.newQuery(GameData.class, "gameToken == g");
123 q.declareParameters("String g");
124 curGame = (GameData) q.execute(gameToken);
125
126 if(curGame == null) {
127 throw new GameTokenError(gameToken);
128 }
129
130 return curGame;
131 }
132}
0133
=== modified file 'src/au/edu/unimelb/csse/mugle/server/model/KeyValuePairData.java'
--- src/au/edu/unimelb/csse/mugle/server/model/KeyValuePairData.java 2011-03-31 09:56:28 +0000
+++ src/au/edu/unimelb/csse/mugle/server/model/KeyValuePairData.java 2011-04-16 12:23:28 +0000
@@ -109,6 +109,10 @@
109 this.value = value;109 this.value = value;
110 }110 }
111 111
112 public void setUserGameProfile(UserGameProfileData ugp) {
113 this.ugp = ugp;
114 }
115
112 @Override116 @Override
113 public Key getServerKey() {117 public Key getServerKey() {
114 return this.id;118 return this.id;
@@ -132,4 +136,6 @@
132 return KeyValuePair.class;136 return KeyValuePair.class;
133 }137 }
134138
139
140
135}141}
136142
=== added file 'src/au/edu/unimelb/csse/mugle/server/model/KeyValuePairGetter.java'
--- src/au/edu/unimelb/csse/mugle/server/model/KeyValuePairGetter.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/server/model/KeyValuePairGetter.java 2011-04-16 12:23:28 +0000
@@ -0,0 +1,108 @@
1/* Melbourne University Game-based Learning Environment
2 * Copyright (C) 2011 The University of Melbourne
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17package au.edu.unimelb.csse.mugle.server.model;
18
19import javax.jdo.PersistenceManager;
20import javax.jdo.Query;
21
22import au.edu.unimelb.csse.mugle.server.PMF;
23import au.edu.unimelb.csse.mugle.shared.api.GameTokenError;
24import au.edu.unimelb.csse.mugle.shared.api.KeyError;
25import au.edu.unimelb.csse.mugle.shared.platform.exceptions.UserNotExists;
26
27public class KeyValuePairGetter {
28
29 /**
30 * Gets the KeyValuePair for the key provided from the datastore for the
31 * player currently playing - READ ONLY
32 * @param key the key to look up of the KeyValuePair
33 * @param gameToken the secret game token for the current game, provided by the client
34 * @return The request KeyValuePair - READ ONLY
35 * @throws UserNotExists
36 * @throws GameTokenError
37 * @throws KeyError
38 */
39 public KeyValuePairData getKeyValuePair(String key, String gameToken)
40 throws UserNotExists, GameTokenError, KeyError {
41 PersistenceManager pm = PMF.getManager();
42 try {
43 return getKeyValuePair(pm, key, gameToken);
44 } finally {
45 pm.close();
46 }
47 }
48
49
50 /**
51 * Gets the KeyValuePair for the key provided from the datastore for the
52 * player currently playing, for editing object in datastore
53 * The Persistence Manager must be handled by the caller
54 * @param pm The PersistenceManager
55 * @param key the key to look up of the KeyValuePair
56 * @param gameToken the secret game token for the current game, provided by the client
57 * @return The request KeyValuePair
58 * @throws UserNotExists
59 * @throws GameTokenError
60 * @throws KeyError
61 */
62 public KeyValuePairData getKeyValuePair(PersistenceManager pm, String key, String gameToken)
63 throws UserNotExists, GameTokenError, KeyError {
64 return getKeyValuePair(pm, key, gameToken, false);
65 }
66
67 /**
68 * Gets the KeyValuePair for the key provided from the datastore for the
69 * player currently playing, for editing object in datastore - if the KeyValuePair isnt
70 * found the parameter createIfNotFound determines whether an exception will be thrown, or
71 * if a new KeyValuePair is created and associated to that User's UserGameProfile
72 * The Persistence Manager must be handled by the caller
73 * @param pm The PersistenceManager
74 * @param key the key to look up of the KeyValuePair
75 * @param gameToken the secret game token for the current game, provided by the client
76 * @param createIfNotFound boolean to determine whether a new KeyValuePair is created if its not found.s
77 * @return The request KeyValuePair
78 * @throws UserNotExists
79 * @throws GameTokenError
80 * @throws KeyError
81 */
82 public KeyValuePairData getKeyValuePair(PersistenceManager pm, String key, String gameToken, boolean createIfNotFound)
83 throws UserNotExists, GameTokenError, KeyError {
84 UserGameProfileGetter u = new UserGameProfileGetter();
85 UserGameProfileData ugp = u.getCurrentUserGameProfile(pm, gameToken);
86
87 KeyValuePairData kvp = null;
88
89 Query q = pm.newQuery(KeyValuePairData.class, "key == k && ugp == u");
90 q.declareParameters("String k, UserGameProfileData u");
91 kvp = (KeyValuePairData) q.execute(key, ugp);
92
93 /* If the key value pair isn't found - we want to create one if
94 * createIfNotFound is set to true
95 */
96 if (kvp == null) {
97 if (createIfNotFound) {
98 kvp = new KeyValuePairData();
99 kvp.setKey(key);
100 kvp.setUserGameProfile(ugp);
101 } else {
102 throw new KeyError(key);
103 }
104 }
105
106 return kvp;
107 }
108}
0109
=== modified file 'src/au/edu/unimelb/csse/mugle/server/model/ModelDataClass.java'
--- src/au/edu/unimelb/csse/mugle/server/model/ModelDataClass.java 2011-04-08 11:00:59 +0000
+++ src/au/edu/unimelb/csse/mugle/server/model/ModelDataClass.java 2011-04-16 12:23:28 +0000
@@ -24,7 +24,7 @@
2424
25import com.google.appengine.api.datastore.Key;25import com.google.appengine.api.datastore.Key;
2626
27import au.edu.unimelb.csse.mugle.server.platform.PMF;27import au.edu.unimelb.csse.mugle.server.PMF;
28import au.edu.unimelb.csse.mugle.shared.model.ModelClass;28import au.edu.unimelb.csse.mugle.shared.model.ModelClass;
2929
30/**30/**
3131
=== modified file 'src/au/edu/unimelb/csse/mugle/server/model/ModelWrapper.java'
--- src/au/edu/unimelb/csse/mugle/server/model/ModelWrapper.java 2011-04-08 11:00:59 +0000
+++ src/au/edu/unimelb/csse/mugle/server/model/ModelWrapper.java 2011-04-16 12:23:28 +0000
@@ -22,7 +22,7 @@
22import javax.jdo.PersistenceManager;22import javax.jdo.PersistenceManager;
2323
24import au.edu.unimelb.csse.mugle.server.model.annotations.*;24import au.edu.unimelb.csse.mugle.server.model.annotations.*;
25import au.edu.unimelb.csse.mugle.server.platform.PMF;25import au.edu.unimelb.csse.mugle.server.PMF;
26import au.edu.unimelb.csse.mugle.shared.model.*;26import au.edu.unimelb.csse.mugle.shared.model.*;
27import au.edu.unimelb.csse.mugle.shared.model.annotations.*;27import au.edu.unimelb.csse.mugle.shared.model.annotations.*;
28import au.edu.unimelb.csse.mugle.shared.platform.exceptions.UserPrivilegeException;28import au.edu.unimelb.csse.mugle.shared.platform.exceptions.UserPrivilegeException;
2929
=== modified file 'src/au/edu/unimelb/csse/mugle/server/model/UserAchievementData.java'
--- src/au/edu/unimelb/csse/mugle/server/model/UserAchievementData.java 2011-03-31 09:56:28 +0000
+++ src/au/edu/unimelb/csse/mugle/server/model/UserAchievementData.java 2011-04-16 12:23:28 +0000
@@ -73,7 +73,7 @@
73 this.ugp = ugp;73 this.ugp = ugp;
74 this.achievement = achievement;74 this.achievement = achievement;
75 this.achieved = true;75 this.achieved = true;
76 this.progress = 1; //default assume 1/176 this.progress = 0;
77 }77 }
78 78
79 //Constructor for achievements with progress79 //Constructor for achievements with progress
@@ -136,15 +136,21 @@
136 136
137 // Misc methods137 // Misc methods
138 138
139 public void addProgress(int additionalProgress) {139 public boolean addProgress(int additionalProgress) {
140 /*If the progress is greater or equal to the max progress of the achievement,140 /*If the progress is greater or equal to the max progress of the achievement,
141 * set it to be achieved, and set the progress to maxProgress141 * set it to be achieved, and set the progress to maxProgress
142 */142 */
143 if (this.progress + additionalProgress >= this.achievement.getMaxProgress()) {143 int maxProgress = this.achievement.getMaxProgress();
144 this.progress = this.achievement.getMaxProgress();144 int prog = this.progress + additionalProgress;
145
146 if (prog >= maxProgress) {
147 this.progress = maxProgress;
145 this.achieved = true;148 this.achieved = true;
149 return true;
146 } else {150 } else {
147 this.progress += additionalProgress;151 this.progress = prog;
152 this.achieved = false; // If for some reason, they change the max progress to be less.
153 return false;
148 }154 }
149 }155 }
150 156
151157
=== added file 'src/au/edu/unimelb/csse/mugle/server/model/UserAchievementGetter.java'
--- src/au/edu/unimelb/csse/mugle/server/model/UserAchievementGetter.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/server/model/UserAchievementGetter.java 2011-04-16 12:23:28 +0000
@@ -0,0 +1,84 @@
1/* Melbourne University Game-based Learning Environment
2 * Copyright (C) 2011 The University of Melbourne
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18package au.edu.unimelb.csse.mugle.server.model;
19
20import javax.jdo.PersistenceManager;
21import javax.jdo.Query;
22
23import au.edu.unimelb.csse.mugle.server.PMF;
24import au.edu.unimelb.csse.mugle.shared.api.GameTokenError;
25import au.edu.unimelb.csse.mugle.shared.platform.exceptions.AchievementNotExists;
26import au.edu.unimelb.csse.mugle.shared.platform.exceptions.UserNotExists;
27
28public class UserAchievementGetter {
29 /**
30 * Gets the UserAchievement for the requested achievement of the user currently
31 * playing the current game - READ ONLY
32 * @param achievementName the name of the achievement requested
33 * @param gameToken the secret game token for the current game, provided by the client
34 * @return The UserAchievement - READ ONLY
35 * @throws UserNotExists
36 * @throws GameTokenError
37 * @throws AchievementNotExists
38 */
39 public UserAchievementData getUserAchievement(String achievementName, String gameToken)
40 throws UserNotExists, GameTokenError, AchievementNotExists {
41 PersistenceManager pm = PMF.getManager();
42 try {
43 return getUserAchievement(pm, achievementName, gameToken);
44 } finally {
45 pm.close();
46 }
47 }
48
49 /**
50 * Gets the UserAchievement for the requested achievement of the user currently
51 * playing the current game, for editing object in datastore
52 * The PersistenceManager must be handled by the caller
53 * @param pm the Persistence Manager
54 * @param achievementName the name of the achievement requested
55 * @param gameToken the secret game token for the current game, provided by the client
56 * @return The UserAchievement
57 * @throws UserNotExists
58 * @throws GameTokenError
59 * @throws AchievementNotExists
60 */
61 public UserAchievementData getUserAchievement(PersistenceManager pm, String achievementName, String gameToken)
62 throws UserNotExists, GameTokenError, AchievementNotExists {
63 UserGameProfileGetter u = new UserGameProfileGetter();
64 AchievementGetter a = new AchievementGetter();
65
66 UserGameProfileData ugp = u.getCurrentUserGameProfile(pm, gameToken);
67 AchievementData achievement = a.getAchievement(pm, achievementName, gameToken);
68
69 Query q = pm.newQuery(UserAchievementData.class, "ugp == u && achievement == a");
70 q.declareParameters("UserGameProfileData ugp, AchievementData a");
71 UserAchievementData ua = (UserAchievementData) q.execute(ugp, achievement);
72
73 /* If we can't find the UserAchievement it makes sense to create one
74 * if the UserGameProfile and the Achievement exist.
75 */
76 if (ua == null) {
77 ua = new UserAchievementData();
78 ua.setAchievement(achievement);
79 ua.setUserGameProfile(ugp);
80 }
81
82 return ua;
83 }
84}
085
=== modified file 'src/au/edu/unimelb/csse/mugle/server/model/UserData.java'
--- src/au/edu/unimelb/csse/mugle/server/model/UserData.java 2011-04-08 11:00:59 +0000
+++ src/au/edu/unimelb/csse/mugle/server/model/UserData.java 2011-04-16 12:23:28 +0000
@@ -42,6 +42,10 @@
42 @PrimaryKey42 @PrimaryKey
43 @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)43 @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
44 private Key id;44 private Key id;
45
46 @UserLevel(privateView=Role.DEVELOPER, publicView=Role.DEVELOPER, mappedBy="googleID")
47 @Persistent
48 private String googleID; //Unique userID provided by google
45 49
46 @UserLevel(privateView=Role.DEVELOPER, publicView=Role.DEVELOPER, mappedBy="urlName")50 @UserLevel(privateView=Role.DEVELOPER, publicView=Role.DEVELOPER, mappedBy="urlName")
47 @Persistent 51 @Persistent
@@ -80,6 +84,7 @@
8084
81 this.devTeams = new HashSet<Key>();85 this.devTeams = new HashSet<Key>();
82 this.ugps = new HashSet<Key>();86 this.ugps = new HashSet<Key>();
87 this.googleID = null;
83 this.urlName = null;88 this.urlName = null;
84 this.fullName = null;89 this.fullName = null;
85 this.email = null;90 this.email = null;
@@ -95,6 +100,7 @@
95 100
96 this.urlName = url_name;101 this.urlName = url_name;
97 this.fullName = full_name;102 this.fullName = full_name;
103 this.googleID = null;
98 //TODO: check that email is unique and valid.104 //TODO: check that email is unique and valid.
99 this.email = email;105 this.email = email;
100 this.role = role;106 this.role = role;
@@ -112,6 +118,10 @@
112 public String getUrlName() {118 public String getUrlName() {
113 return this.urlName;119 return this.urlName;
114 }120 }
121
122 public String getGoogleID() {
123 return googleID;
124 }
115125
116 public String getFullName() {126 public String getFullName() {
117 return this.fullName;127 return this.fullName;
@@ -147,6 +157,10 @@
147 //TODO: check that newName is unique.157 //TODO: check that newName is unique.
148 this.urlName = newName;158 this.urlName = newName;
149 }159 }
160
161 public void setGoogleID(String googleID) {
162 this.googleID = googleID;
163 }
150 164
151 /* This can only be changed by an Admin, again we need an Admin control panel */165 /* This can only be changed by an Admin, again we need an Admin control panel */
152 public void setRole(Role newRole) {166 public void setRole(Role newRole) {
153167
=== added file 'src/au/edu/unimelb/csse/mugle/server/model/UserGameProfileGetter.java'
--- src/au/edu/unimelb/csse/mugle/server/model/UserGameProfileGetter.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/server/model/UserGameProfileGetter.java 2011-04-16 12:23:28 +0000
@@ -0,0 +1,113 @@
1/* Melbourne University Game-based Learning Environment
2 * Copyright (C) 2011 The University of Melbourne
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18package au.edu.unimelb.csse.mugle.server.model;
19
20import javax.jdo.PersistenceManager;
21import javax.jdo.Query;
22
23import au.edu.unimelb.csse.mugle.server.PMF;
24import au.edu.unimelb.csse.mugle.shared.api.GameTokenError;
25import au.edu.unimelb.csse.mugle.shared.platform.exceptions.UserGameProfileNotExists;
26import au.edu.unimelb.csse.mugle.shared.platform.exceptions.UserNotExists;
27
28public class UserGameProfileGetter {
29 /**
30 * Gets the UserGameProfile by its Primary Key - READ ONLY
31 * @param primaryKey
32 * @return The UserGameProfile - READ ONLY
33 * @throws UserGameProfileNotExists
34 */
35 public UserGameProfileData getUserGameProfile(Long primaryKey)
36 throws UserGameProfileNotExists {
37 PersistenceManager pm = PMF.getManager();
38 try {
39 return getUserGameProfile(pm, primaryKey);
40 } finally {
41 pm.close();
42 }
43 }
44
45 /**
46 * Gets the UserGameProfile by its Primary Key, for editing the object in the datastore
47 * PersistenceManager must be handled by the caller
48 * @param pm The PersistenceManager
49 * @param primaryKey
50 * @return The UserGameProfile
51 * @throws UserGameProfileNotExists
52 */
53 public UserGameProfileData getUserGameProfile(PersistenceManager pm, Long primaryKey)
54 throws UserGameProfileNotExists {
55 UserGameProfileData ugp = pm.getObjectById(UserGameProfileData.class, primaryKey);
56
57 if (ugp == null) {
58 throw new UserGameProfileNotExists(primaryKey);
59 }
60 return ugp;
61 }
62
63 /**
64 * Gets the UserGameProfile of the current user based on the game they're playing (read only)
65 * @param gameToken the secret game token for the current game, provided by the client
66 * @return the UserGameProfile - READ ONLY
67 * @throws UserNotExists
68 * @throws GameTokenError
69 */
70 public UserGameProfileData getCurrentUserGameProfile(String gameToken)
71 throws UserNotExists, GameTokenError {
72 PersistenceManager pm = PMF.getManager();
73 try {
74 return getCurrentUserGameProfile(pm, gameToken);
75 } finally {
76 pm.close();
77 }
78 }
79
80 /**
81 * Gets the UserGameProfile of the current user based on the game they're playing,
82 * for editing object in datstore
83 * The Persistence Manager must be handled by the caller
84 * @param pm The Persistence Manager
85 * @param gameToken the secret game token for the current game, provided by the client
86 * @return The UserGameProfile of the current user / game.
87 * @throws UserNotExists
88 * @throws GameTokenError
89 */
90 public UserGameProfileData getCurrentUserGameProfile(PersistenceManager pm, String gameToken)
91 throws UserNotExists, GameTokenError {
92 UserGetter u = new UserGetter();
93 GameGetter g = new GameGetter();
94 UserData curUser = u.getCurrentUser(pm);
95 GameData curGame = g.getCurrentGame(pm, gameToken);
96 UserGameProfileData ugp = null;
97
98 Query q = pm.newQuery(UserGameProfileData.class, "user == u && game == g");
99 q.declareParameters("UserData u, GameData g");
100 ugp = (UserGameProfileData) q.execute(curUser, curGame);
101
102 /* If we can't find the UserGameProfile it makes sense to create one
103 * if the user is playing the game
104 */
105 if (ugp == null) {
106 ugp = new UserGameProfileData();
107 ugp.setGame(curGame);
108 ugp.setUser(curUser);
109 }
110 return ugp;
111 }
112
113}
0114
=== added file 'src/au/edu/unimelb/csse/mugle/server/model/UserGetter.java'
--- src/au/edu/unimelb/csse/mugle/server/model/UserGetter.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/server/model/UserGetter.java 2011-04-16 12:23:28 +0000
@@ -0,0 +1,160 @@
1/* Melbourne University Game-based Learning Environment
2 * Copyright (C) 2011 The University of Melbourne
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18package au.edu.unimelb.csse.mugle.server.model;
19
20import javax.jdo.PersistenceManager;
21import javax.jdo.Query;
22
23import au.edu.unimelb.csse.mugle.client.LoginInfo;
24import au.edu.unimelb.csse.mugle.server.LoginServiceImpl;
25import au.edu.unimelb.csse.mugle.server.PMF;
26import au.edu.unimelb.csse.mugle.shared.platform.exceptions.UserNotExists;
27
28public class UserGetter {
29
30 /**
31 * Gets a User based on the Primary Key
32 * @param primaryKey
33 * @return The User class - READ ONLY
34 * @throws UserNotExists
35 */
36 public UserData getUser(Long primaryKey) throws UserNotExists {
37 PersistenceManager pm = PMF.getManager();
38 try {
39 return getUser(pm, primaryKey);
40 } finally {
41 pm.close();
42 }
43 }
44
45 /**
46 * Gets a User based on their Primary Key, for editing object in datstore
47 * Persistence Manager must be handle by caller
48 * @param pm The Persistence Manager
49 * @param primaryKey
50 * @return The User class
51 * @throws UserNotExists
52 */
53 public UserData getUser(PersistenceManager pm, Long primaryKey) throws UserNotExists {
54 UserData u = pm.getObjectById(UserData.class, primaryKey);
55
56 if (u == null) {
57 throw new UserNotExists(primaryKey);
58 }
59
60 return u;
61 }
62 /**
63 * Gets a User based on their urlName - READ ONLY
64 * @param name
65 * @return The User class - READ ONLY
66 * @throws UserNotExists
67 */
68 public UserData getUserByName(String name) throws UserNotExists {
69 PersistenceManager pm = PMF.getManager();
70 try {
71 return getUserByName(pm, name);
72 } finally {
73 pm.close();
74 }
75 }
76
77 /**
78 * Gets a User based on their urlName, for editing object in datstore
79 * Persistence Manager must be handle by caller
80 * @param pm The Persistence Manager
81 * @param name
82 * @return The User class
83 * @throws UserNotExists
84 */
85 public UserData getUserByName(PersistenceManager pm, String name) throws UserNotExists {
86 Query q = pm.newQuery(UserData.class, "urlName == u");
87 q.declareParameters("String u");
88 UserData u = (UserData) q.execute(name);
89
90 if (u == null) {
91 throw new UserNotExists(name);
92 }
93
94 return u;
95 }
96
97 /**
98 * Gets a User based on their unique google ID - READ ONLY
99 * @param googleID
100 * @return The User class - READ ONLY
101 * @throws UserNotExists
102 */
103 public UserData getUser(String googleID) throws UserNotExists {
104 PersistenceManager pm = PMF.getManager();
105 try {
106 return getUser(pm, googleID);
107 } finally {
108 pm.close();
109 }
110 }
111
112 /**
113 * Gets a User based on their unique google ID, for editing object in datstore
114 * Persistence Manager must be handle by caller
115 * @param pm The Persistence Manager
116 * @param googleID
117 * @return The User class
118 * @throws UserNotExists
119 */
120 public UserData getUser(PersistenceManager pm, String googleID) throws UserNotExists {
121 Query q = pm.newQuery(UserData.class, "googleID == u");
122 q.declareParameters("String u");
123 UserData u = (UserData) q.execute(googleID);
124
125 if (u == null) {
126 throw new UserNotExists(googleID);
127 }
128
129 return u;
130 }
131
132 /**
133 * Gets the currently logged in User - READ ONLY
134 * @return the User - read only
135 * @throws UserNotExists
136 */
137 public UserData getCurrentUser() throws UserNotExists {
138 PersistenceManager pm = PMF.getManager();
139 try {
140 return getCurrentUser(pm);
141 } finally {
142 pm.close();
143 }
144 }
145
146 /**
147 * Gets the currently logged in User, for editing object in datstore
148 * Persistence Manager must be handled by the caller
149 * @param pm The Persistence Manager
150 * @return the current User
151 * @throws UserNotExists
152 */
153 public UserData getCurrentUser(PersistenceManager pm) throws UserNotExists {
154 LoginServiceImpl loginService = new LoginServiceImpl();
155 LoginInfo loginInfo = loginService.getCurrentUser();
156
157 return getUser(pm, loginInfo.getUserID());
158 }
159
160}
0161
=== modified file 'src/au/edu/unimelb/csse/mugle/server/platform/AdminServiceImpl.java'
--- src/au/edu/unimelb/csse/mugle/server/platform/AdminServiceImpl.java 2011-03-30 15:46:59 +0000
+++ src/au/edu/unimelb/csse/mugle/server/platform/AdminServiceImpl.java 2011-04-16 12:23:28 +0000
@@ -22,6 +22,7 @@
22import au.edu.unimelb.csse.mugle.shared.model.*;22import au.edu.unimelb.csse.mugle.shared.model.*;
23import au.edu.unimelb.csse.mugle.shared.platform.exceptions.*;23import au.edu.unimelb.csse.mugle.shared.platform.exceptions.*;
2424
25@SuppressWarnings("serial")
25public class AdminServiceImpl extends DeveloperServiceImpl implements AdminService {26public class AdminServiceImpl extends DeveloperServiceImpl implements AdminService {
2627
27 @Override28 @Override
2829
=== modified file 'src/au/edu/unimelb/csse/mugle/server/platform/DeveloperServiceImpl.java'
--- src/au/edu/unimelb/csse/mugle/server/platform/DeveloperServiceImpl.java 2011-03-30 15:46:59 +0000
+++ src/au/edu/unimelb/csse/mugle/server/platform/DeveloperServiceImpl.java 2011-04-16 12:23:28 +0000
@@ -22,6 +22,7 @@
22import au.edu.unimelb.csse.mugle.shared.model.*;22import au.edu.unimelb.csse.mugle.shared.model.*;
23import au.edu.unimelb.csse.mugle.shared.platform.exceptions.*;23import au.edu.unimelb.csse.mugle.shared.platform.exceptions.*;
2424
25@SuppressWarnings("serial")
25public class DeveloperServiceImpl extends UserServiceImpl implements DeveloperService {26public class DeveloperServiceImpl extends UserServiceImpl implements DeveloperService {
2627
27 @Override28 @Override
2829
=== modified file 'src/au/edu/unimelb/csse/mugle/server/platform/ServiceHelper.java'
--- src/au/edu/unimelb/csse/mugle/server/platform/ServiceHelper.java 2011-03-30 15:46:59 +0000
+++ src/au/edu/unimelb/csse/mugle/server/platform/ServiceHelper.java 2011-04-16 12:23:28 +0000
@@ -25,6 +25,7 @@
25import com.google.appengine.api.datastore.Query;25import com.google.appengine.api.datastore.Query;
26import com.google.appengine.api.datastore.Query.FilterOperator;26import com.google.appengine.api.datastore.Query.FilterOperator;
2727
28import au.edu.unimelb.csse.mugle.server.PMF;
28import au.edu.unimelb.csse.mugle.server.model.*;29import au.edu.unimelb.csse.mugle.server.model.*;
29import au.edu.unimelb.csse.mugle.shared.model.*;30import au.edu.unimelb.csse.mugle.shared.model.*;
30import au.edu.unimelb.csse.mugle.shared.platform.exceptions.*;31import au.edu.unimelb.csse.mugle.shared.platform.exceptions.*;
3132
=== added directory 'src/au/edu/unimelb/csse/mugle/shared/api'
=== added file 'src/au/edu/unimelb/csse/mugle/shared/api/Badge.java'
--- src/au/edu/unimelb/csse/mugle/shared/api/Badge.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/api/Badge.java 2011-04-16 12:23:28 +0000
@@ -0,0 +1,85 @@
1/* Melbourne University Game-based Learning Environment
2 * Copyright (C) 2011 The University of Melbourne
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published
6 * by the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18package au.edu.unimelb.csse.mugle.shared.api;
19
20import java.io.Serializable;
21
22/** Provides static (user-independent) information about a badge.
23 * This is the information that the developers have provided to describe a
24 * badge in the MUGLE control panel.
25 */
26public class Badge implements Serializable {
27 private static final long serialVersionUID = 4335025238357031611L;
28
29 private String name;
30 private String displayName;
31 private String description;
32 private int maxProgress;
33
34 public Badge()
35 {
36 this.name = "";
37 this.displayName = "";
38 this.description = "";
39 this.maxProgress = 0;
40 }
41
42 /** Construct a new Badge object. */
43 public Badge(String name, String displayName, String description,
44 int maxProgress)
45 {
46 this.name = name;
47 this.displayName = displayName;
48 this.description = description;
49 this.maxProgress = maxProgress;
50 }
51
52 /** The short name used to identify a badge. */
53 public String getName() {
54 return name;
55 }
56
57 /** The long "friendly" string which names the badge for users. */
58 public String getDisplayName() {
59 return displayName;
60 }
61
62 /** The even longer text which describes how to earn the badge.
63 * This should be in the form of an instruction, such as "rescue the
64 * princess."
65 */
66 public String getDescription() {
67 return description;
68 }
69
70 /** For progress badges, the total number of progress units required to
71 * earn the badge. For non-progress badges, 0.
72 */
73 public int getMaxProgress() {
74 return maxProgress;
75 }
76
77 @Override
78 public String toString() {
79 return "Badge [" +
80 this.name + ", " +
81 this.displayName + ", " +
82 this.description + ", " +
83 this.maxProgress + "]";
84 }
85}
086
=== added file 'src/au/edu/unimelb/csse/mugle/shared/api/BadgeError.java'
--- src/au/edu/unimelb/csse/mugle/shared/api/BadgeError.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/api/BadgeError.java 2011-04-16 12:23:28 +0000
@@ -0,0 +1,34 @@
1/* Melbourne University Game-based Learning Environment
2 * Copyright (C) 2011 The University of Melbourne
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published
6 * by the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18package au.edu.unimelb.csse.mugle.shared.api;
19
20/** An error relating to the badge service.
21 */
22public class BadgeError extends Exception {
23 private static final long serialVersionUID = -5517149280375900036L;
24
25 public BadgeError()
26 {
27 super();
28 }
29
30 public BadgeError(String message)
31 {
32 super(message);
33 }
34}
035
=== added file 'src/au/edu/unimelb/csse/mugle/shared/api/GameTokenError.java'
--- src/au/edu/unimelb/csse/mugle/shared/api/GameTokenError.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/api/GameTokenError.java 2011-04-16 12:23:28 +0000
@@ -0,0 +1,34 @@
1/* Melbourne University Game-based Learning Environment
2 * Copyright (C) 2011 The University of Melbourne
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published
6 * by the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18package au.edu.unimelb.csse.mugle.shared.api;
19
20/** An error passing a game token to one of the API methods.
21 */
22public class GameTokenError extends Exception {
23 private static final long serialVersionUID = 4167419343442742185L;
24
25 public GameTokenError()
26 {
27 super();
28 }
29
30 public GameTokenError(String gameToken)
31 {
32 super("A game with the gameToken: " + gameToken + " does not exist.");
33 }
34}
035
=== added file 'src/au/edu/unimelb/csse/mugle/shared/api/KeyError.java'
--- src/au/edu/unimelb/csse/mugle/shared/api/KeyError.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/api/KeyError.java 2011-04-16 12:23:28 +0000
@@ -0,0 +1,43 @@
1/* Melbourne University Game-based Learning Environment
2 * Copyright (C) 2011 The University of Melbourne
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published
6 * by the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18package au.edu.unimelb.csse.mugle.shared.api;
19
20/** An error for the key-value store; a key was not found.
21 */
22public class KeyError extends Exception {
23 private static final long serialVersionUID = 2248222166311987494L;
24
25 private String key;
26
27 public KeyError()
28 {
29 super();
30 this.key = null;
31 }
32
33 public KeyError(String key)
34 {
35 super("Key not found: " + key);
36 this.key = key;
37 }
38
39 public String getKey()
40 {
41 return this.key;
42 }
43}
044
=== modified file 'src/au/edu/unimelb/csse/mugle/shared/model/Achievement.java'
--- src/au/edu/unimelb/csse/mugle/shared/model/Achievement.java 2011-04-08 10:13:04 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/model/Achievement.java 2011-04-16 12:23:28 +0000
@@ -23,12 +23,17 @@
2323
24import au.edu.unimelb.csse.mugle.shared.model.annotations.*;24import au.edu.unimelb.csse.mugle.shared.model.annotations.*;
2525
26@SuppressWarnings("serial")
27@MugleDataWrapper26@MugleDataWrapper
28public class Achievement extends ModelClass<Long, Achievement> {27public class Achievement extends ModelClass<Long, Achievement> {
2928
29 private static final long serialVersionUID = -578289425640382697L;
30
31 // Fields
32
30 private String name;33 private String name;
3134
35 private String displayName;
36
32 private String description;37 private String description;
3338
34 private Game game;39 private Game game;
@@ -43,14 +48,13 @@
43 // Constructors48 // Constructors
44 49
45 public Achievement() {50 public Achievement() {
46
47 this.userAchievementKeys = null;51 this.userAchievementKeys = null;
48 this.name = null;52 this.name = null;
53 this.setDisplayName(null);
49 this.description = null;54 this.description = null;
50 this.maxProgress = null;55 this.maxProgress = null;
51 this.game = null;56 this.game = null;
52 //TODO: Image57 //TODO: Image
53
54 }58 }
5559
56 // Getters60 // Getters
@@ -59,6 +63,10 @@
59 return this.name;63 return this.name;
60 }64 }
6165
66 public String getDisplayName() {
67 return displayName;
68 }
69
62 public String getDescription() {70 public String getDescription() {
63 return this.description;71 return this.description;
64 }72 }
@@ -91,6 +99,10 @@
91 this.name = newName;99 this.name = newName;
92 }100 }
93101
102 public void setDisplayName(String displayName) {
103 this.displayName = displayName;
104 }
105
94 public void setDescription(String newDescription) {106 public void setDescription(String newDescription) {
95 this.description = newDescription;107 this.description = newDescription;
96 }108 }
97109
=== modified file 'src/au/edu/unimelb/csse/mugle/shared/model/DevTeam.java'
--- src/au/edu/unimelb/csse/mugle/shared/model/DevTeam.java 2011-04-08 10:13:04 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/model/DevTeam.java 2011-04-16 12:23:28 +0000
@@ -23,12 +23,12 @@
2323
24import au.edu.unimelb.csse.mugle.shared.model.annotations.*;24import au.edu.unimelb.csse.mugle.shared.model.annotations.*;
2525
26@SuppressWarnings("serial")
27@MugleDataWrapper26@MugleDataWrapper
28public class DevTeam extends ModelClass<Long, DevTeam> {27public class DevTeam extends ModelClass<Long, DevTeam> {
2928
29 private static final long serialVersionUID = -8745604337821752467L;
30 30
31 // Fields31 //Fields
3232
33 private String urlName; //Must be unique33 private String urlName; //Must be unique
3434
3535
=== modified file 'src/au/edu/unimelb/csse/mugle/shared/model/Game.java'
--- src/au/edu/unimelb/csse/mugle/shared/model/Game.java 2011-04-08 10:13:04 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/model/Game.java 2011-04-16 12:23:28 +0000
@@ -23,11 +23,13 @@
2323
24import au.edu.unimelb.csse.mugle.shared.model.annotations.*;24import au.edu.unimelb.csse.mugle.shared.model.annotations.*;
2525
26@SuppressWarnings("serial")
27@MugleDataWrapper26@MugleDataWrapper
28public class Game extends ModelClass<Long, Game> {27public class Game extends ModelClass<Long, Game> {
2928
30 /** The maximum possible game rating. */29 private static final long serialVersionUID = -5139341163256410284L;
30
31
32 /** The maximum possible game rating. */
31 public static final int MAX_RATING = 100;33 public static final int MAX_RATING = 100;
3234
33 // Fields35 // Fields
@@ -39,6 +41,8 @@
39 private Integer totalRatings; // number of users who have rated this game41 private Integer totalRatings; // number of users who have rated this game
4042
41 private DevTeam devTeam;43 private DevTeam devTeam;
44
45 private String gameToken;
4246
43 private Set<Long> achievementKeys;47 private Set<Long> achievementKeys;
4448
@@ -50,7 +54,7 @@
50 // Constructors54 // Constructors
5155
52 public Game() {56 public Game() {
5357 this.gameToken = null;
54 this.gameVersionKeys = null;58 this.gameVersionKeys = null;
55 this.ugpKeys = null;59 this.ugpKeys = null;
56 this.achievementKeys = null;60 this.achievementKeys = null;
@@ -138,4 +142,12 @@
138 this.ugpKeys = ugps;142 this.ugpKeys = ugps;
139 } 143 }
140144
145 public void setGameToken(String gameToken) {
146 this.gameToken = gameToken;
147 }
148
149 public String getGameToken() {
150 return gameToken;
151 }
152
141}153}
142\ No newline at end of file154\ No newline at end of file
143155
=== modified file 'src/au/edu/unimelb/csse/mugle/shared/model/GameFile.java'
--- src/au/edu/unimelb/csse/mugle/shared/model/GameFile.java 2011-04-08 10:13:04 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/model/GameFile.java 2011-04-16 12:23:28 +0000
@@ -24,19 +24,25 @@
24import au.edu.unimelb.csse.mugle.shared.model.annotations.*;24import au.edu.unimelb.csse.mugle.shared.model.annotations.*;
2525
26@MugleDataWrapper26@MugleDataWrapper
27@SuppressWarnings("serial")
28public class GameFile extends ModelClass<String, GameFile> {27public class GameFile extends ModelClass<String, GameFile> {
2928
3029 private static final long serialVersionUID = -4361821523009813698L;
31 // Fields30
3231 // Fields
32
33 private String path; //path to the file relative to the Game URL33 private String path; //path to the file relative to the Game URL
34 34
35 private String mimeType; //mime type of the file
36
37 private String blobKey; //key to the actual blob
38
35 private Set<Long> gameVersionKeys; //Game versions this file belongs to39 private Set<Long> gameVersionKeys; //Game versions this file belongs to
3640
37 // Constructors41 // Constructors
38 public GameFile() {42 public GameFile() {
39 this.gameVersionKeys = null;43 this.gameVersionKeys = null;
44 this.mimeType = null;
45 this.blobKey = null;
40 this.path = null;46 this.path = null;
41 }47 }
4248
@@ -68,5 +74,21 @@
68 public void setGameVersionKeys(Set<Long> versions) {74 public void setGameVersionKeys(Set<Long> versions) {
69 this.gameVersionKeys = versions;75 this.gameVersionKeys = versions;
70 }76 }
77
78 public void setMimeType(String mimeType) {
79 this.mimeType = mimeType;
80 }
81
82 public String getMimeType() {
83 return mimeType;
84 }
85
86 public void setBlobKey(String blobKey) {
87 this.blobKey = blobKey;
88 }
89
90 public String getBlobKey() {
91 return blobKey;
92 }
71 93
72}94}
7395
=== modified file 'src/au/edu/unimelb/csse/mugle/shared/model/GameVersion.java'
--- src/au/edu/unimelb/csse/mugle/shared/model/GameVersion.java 2011-04-08 10:13:04 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/model/GameVersion.java 2011-04-16 12:23:28 +0000
@@ -24,10 +24,11 @@
24import au.edu.unimelb.csse.mugle.shared.model.annotations.*;24import au.edu.unimelb.csse.mugle.shared.model.annotations.*;
2525
26@MugleDataWrapper26@MugleDataWrapper
27@SuppressWarnings("serial")
28public class GameVersion extends ModelClass<Long, GameVersion> {27public class GameVersion extends ModelClass<Long, GameVersion> {
2928
3029
30 private static final long serialVersionUID = -3598516897405942476L;
31
31 // Fields32 // Fields
32 33
33 /*34 /*
3435
=== modified file 'src/au/edu/unimelb/csse/mugle/shared/model/InvalidRatingException.java'
--- src/au/edu/unimelb/csse/mugle/shared/model/InvalidRatingException.java 2011-03-10 03:38:23 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/model/InvalidRatingException.java 2011-04-16 12:23:28 +0000
@@ -17,8 +17,11 @@
1717
18package au.edu.unimelb.csse.mugle.shared.model;18package au.edu.unimelb.csse.mugle.shared.model;
1919
20@SuppressWarnings("serial")20
21public class InvalidRatingException extends Exception {21public class InvalidRatingException extends Exception {
22
23 private static final long serialVersionUID = 8363848579992882462L;
24
22 public InvalidRatingException(int rating) {25 public InvalidRatingException(int rating) {
23 super("Rating " + rating + " is invalid. Rating must be between 0 and "26 super("Rating " + rating + " is invalid. Rating must be between 0 and "
24 + Game.MAX_RATING + ".");27 + Game.MAX_RATING + ".");
2528
=== modified file 'src/au/edu/unimelb/csse/mugle/shared/model/KeyValuePair.java'
--- src/au/edu/unimelb/csse/mugle/shared/model/KeyValuePair.java 2011-03-30 15:46:59 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/model/KeyValuePair.java 2011-04-16 12:23:28 +0000
@@ -19,12 +19,13 @@
1919
20import au.edu.unimelb.csse.mugle.shared.model.annotations.*;20import au.edu.unimelb.csse.mugle.shared.model.annotations.*;
2121
22@SuppressWarnings("serial")
23@MugleDataWrapper22@MugleDataWrapper
24public class KeyValuePair extends ModelClass<Long, KeyValuePair> {23public class KeyValuePair extends ModelClass<Long, KeyValuePair> {
2524
2625
27 // Fields26 private static final long serialVersionUID = 2222512665326609908L;
27
28 // Fields
2829
29 private UserGameProfile ugp;30 private UserGameProfile ugp;
3031
@@ -39,8 +40,7 @@
39 this.ugp = null;40 this.ugp = null;
40 this.value = null;41 this.value = null;
41 }42 }
4243
43
44 // Getters44 // Getters
4545
46 public String getKey() {46 public String getKey() {
4747
=== modified file 'src/au/edu/unimelb/csse/mugle/shared/model/PromotedGame.java'
--- src/au/edu/unimelb/csse/mugle/shared/model/PromotedGame.java 2011-03-30 15:46:59 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/model/PromotedGame.java 2011-04-16 12:23:28 +0000
@@ -19,13 +19,13 @@
1919
20import au.edu.unimelb.csse.mugle.shared.model.annotations.*;20import au.edu.unimelb.csse.mugle.shared.model.annotations.*;
2121
22@SuppressWarnings("serial")
23@MugleDataWrapper22@MugleDataWrapper
24public class PromotedGame extends ModelClass<String, PromotedGame> {23public class PromotedGame extends ModelClass<String, PromotedGame> {
2524
25 private static final long serialVersionUID = -7822465832242079100L;
2626
27 // Fields27 // Fields
28 28
29 private String urlName;29 private String urlName;
3030
31 private GameVersion gameVersion;31 private GameVersion gameVersion;
3232
=== modified file 'src/au/edu/unimelb/csse/mugle/shared/model/User.java'
--- src/au/edu/unimelb/csse/mugle/shared/model/User.java 2011-04-08 10:13:04 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/model/User.java 2011-04-16 12:23:28 +0000
@@ -23,13 +23,15 @@
2323
24import au.edu.unimelb.csse.mugle.shared.model.annotations.*;24import au.edu.unimelb.csse.mugle.shared.model.annotations.*;
2525
26@SuppressWarnings("serial")
27@MugleDataWrapper26@MugleDataWrapper
28public class User extends ModelClass<Long, User> {27public class User extends ModelClass<Long, User> {
2928
3029 private static final long serialVersionUID = 3216382827435913653L;
31 // Fields30
3231 //Fields
32
33 private String googleID; //Unique id provided by google
34
33 private String urlName; //Must be unique35 private String urlName; //Must be unique
3436
35 private String fullName;37 private String fullName;
@@ -48,7 +50,7 @@
48 // Constructors50 // Constructors
4951
50 public User() {52 public User() {
5153 this.googleID = null;
52 this.devTeamKeys = null;54 this.devTeamKeys = null;
53 this.ugpKeys = null;55 this.ugpKeys = null;
54 this.urlName = null;56 this.urlName = null;
@@ -102,6 +104,10 @@
102 public Class<User> getClassType() {104 public Class<User> getClassType() {
103 return User.class;105 return User.class;
104 }106 }
107
108 public String getGoogleID() {
109 return googleID;
110 }
105111
106 // Setters112 // Setters
107 113
@@ -130,5 +136,9 @@
130 public void setActive(Boolean active) {136 public void setActive(Boolean active) {
131 this.active = active;137 this.active = active;
132 }138 }
133 139
140 public void setGoogleID(String googleID) {
141 this.googleID = googleID;
142 }
143
134}144}
135145
=== modified file 'src/au/edu/unimelb/csse/mugle/shared/model/UserAchievement.java'
--- src/au/edu/unimelb/csse/mugle/shared/model/UserAchievement.java 2011-03-30 15:46:59 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/model/UserAchievement.java 2011-04-16 12:23:28 +0000
@@ -19,12 +19,10 @@
1919
20import au.edu.unimelb.csse.mugle.shared.model.annotations.*;20import au.edu.unimelb.csse.mugle.shared.model.annotations.*;
2121
22@SuppressWarnings("serial")
23@MugleDataWrapper22@MugleDataWrapper
24public class UserAchievement extends ModelClass<Long, UserAchievement> {23public class UserAchievement extends ModelClass<Long, UserAchievement> {
2524
26 25 private static final long serialVersionUID = 3314647480043897974L;
27 // Fields
2826
29 private UserGameProfile ugp;27 private UserGameProfile ugp;
30 28
@@ -34,9 +32,6 @@
34 32
35 private Integer progress;33 private Integer progress;
36 34
37 //By default assume a lack of this object means no progress towards achievement
38
39
40 // Constructors35 // Constructors
4136
42 public UserAchievement() {37 public UserAchievement() {
@@ -46,7 +41,6 @@
46 this.progress = null;41 this.progress = null;
47 }42 }
48 43
49
50 // Getters44 // Getters
51 45
52 public UserGameProfile getUserGameProfile() {46 public UserGameProfile getUserGameProfile() {
@@ -80,7 +74,7 @@
80 this.achievement = achievement;74 this.achievement = achievement;
81 }75 }
8276
83 public void setProgress(Integer progress) {77 public void setProgress(Integer progress) {
84 this.progress = progress;78 this.progress = progress;
85 }79 }
8680
8781
=== modified file 'src/au/edu/unimelb/csse/mugle/shared/model/UserGameProfile.java'
--- src/au/edu/unimelb/csse/mugle/shared/model/UserGameProfile.java 2011-04-08 10:13:04 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/model/UserGameProfile.java 2011-04-16 12:23:28 +0000
@@ -23,12 +23,13 @@
2323
24import au.edu.unimelb.csse.mugle.shared.model.annotations.*;24import au.edu.unimelb.csse.mugle.shared.model.annotations.*;
2525
26@SuppressWarnings("serial")
27@MugleDataWrapper26@MugleDataWrapper
28public class UserGameProfile extends ModelClass<Long, UserGameProfile> {27public class UserGameProfile extends ModelClass<Long, UserGameProfile> {
2928
3029 private static final long serialVersionUID = 4735516690085498233L;
31 // Fields30
31 // Fields
32
32 private Integer highscore;33 private Integer highscore;
3334
34 private User user;35 private User user;
@@ -87,7 +88,6 @@
87 return UserGameProfile.class;88 return UserGameProfile.class;
88 }89 }
89 90
90
91 // Setters91 // Setters
9292
93 public void setGame(Game game) {93 public void setGame(Game game) {
@@ -101,7 +101,7 @@
101 /* can only be set by the current Game */101 /* can only be set by the current Game */
102 public void setHighscore(Integer newScore) {102 public void setHighscore(Integer newScore) {
103 this.highscore = newScore;103 this.highscore = newScore;
104 }104 }
105105
106 public void setKeyValuePairKeys(Set<Long> keyValuePair) {106 public void setKeyValuePairKeys(Set<Long> keyValuePair) {
107 this.keyValuePairKeys = keyValuePair;107 this.keyValuePairKeys = keyValuePair;
108108
=== added file 'src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/AchievementNotExists.java'
--- src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/AchievementNotExists.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/AchievementNotExists.java 2011-04-16 12:23:28 +0000
@@ -0,0 +1,40 @@
1/* Melbourne University Game-based Learning Environment
2 * Copyright (C) 2011 The University of Melbourne
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18package au.edu.unimelb.csse.mugle.shared.platform.exceptions;
19
20import java.io.Serializable;
21
22public class AchievementNotExists extends Exception implements Serializable {
23 /**
24 *
25 */
26 private static final long serialVersionUID = 1007635148933156162L;
27
28 public AchievementNotExists() {
29 super();
30 }
31
32 public AchievementNotExists(String gameName, String name) {
33 super("Achievement '" + name + "' does not exist for game '"
34 + gameName + "'");
35 }
36
37 public AchievementNotExists(Long primaryKey) {
38 super("Achievement with id '" + primaryKey + "' does not exist");
39 }
40}
041
=== modified file 'src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/DevTeamExists.java'
--- src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/DevTeamExists.java 2011-03-16 12:12:34 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/DevTeamExists.java 2011-04-16 12:23:28 +0000
@@ -24,9 +24,13 @@
24/**24/**
25 * Exception used when a new dev team is to be created but the team already exists.25 * Exception used when a new dev team is to be created but the team already exists.
26 */26 */
27@SuppressWarnings("serial")
28public class DevTeamExists extends Exception implements Serializable {27public class DevTeamExists extends Exception implements Serializable {
29 28
29 /**
30 *
31 */
32 private static final long serialVersionUID = -1358761246676093332L;
33
30 public DevTeamExists() {34 public DevTeamExists() {
31 super();35 super();
32 }36 }
3337
=== modified file 'src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/DevTeamNotExists.java'
--- src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/DevTeamNotExists.java 2011-03-16 12:12:34 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/DevTeamNotExists.java 2011-04-16 12:23:28 +0000
@@ -24,9 +24,13 @@
24/**24/**
25 * Exception used when a given dev team does not exist.25 * Exception used when a given dev team does not exist.
26 */26 */
27@SuppressWarnings("serial")
28public class DevTeamNotExists extends Exception implements Serializable {27public class DevTeamNotExists extends Exception implements Serializable {
2928
29 /**
30 *
31 */
32 private static final long serialVersionUID = -4803672172249761591L;
33
30 public DevTeamNotExists() {34 public DevTeamNotExists() {
31 super();35 super();
32 }36 }
3337
=== modified file 'src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameExists.java'
--- src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameExists.java 2011-03-16 12:12:34 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameExists.java 2011-04-16 12:23:28 +0000
@@ -24,9 +24,13 @@
24/**24/**
25 * Exception used when a new game is to be created but the game already exists.25 * Exception used when a new game is to be created but the game already exists.
26 */26 */
27@SuppressWarnings("serial")
28public class GameExists extends Exception implements Serializable {27public class GameExists extends Exception implements Serializable {
2928
29 /**
30 *
31 */
32 private static final long serialVersionUID = 77823808801952791L;
33
30 public GameExists() {34 public GameExists() {
31 super();35 super();
32 }36 }
3337
=== modified file 'src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameNotExists.java'
--- src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameNotExists.java 2011-03-16 12:12:34 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameNotExists.java 2011-04-16 12:23:28 +0000
@@ -24,9 +24,13 @@
24/**24/**
25 * Exception used when a given game does not exists.25 * Exception used when a given game does not exists.
26 */26 */
27@SuppressWarnings("serial")
28public class GameNotExists extends Exception implements Serializable {27public class GameNotExists extends Exception implements Serializable {
29 28
29 /**
30 *
31 */
32 private static final long serialVersionUID = -921450195750245805L;
33
30 public GameNotExists() {34 public GameNotExists() {
31 super();35 super();
32 }36 }
3337
=== modified file 'src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameVersionExists.java'
--- src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameVersionExists.java 2011-03-20 11:06:48 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameVersionExists.java 2011-04-16 12:23:28 +0000
@@ -24,9 +24,13 @@
24/**24/**
25 * Exception used when a new game version is to be created but the game version already exists.25 * Exception used when a new game version is to be created but the game version already exists.
26 */26 */
27@SuppressWarnings("serial")
28public class GameVersionExists extends Exception implements Serializable {27public class GameVersionExists extends Exception implements Serializable {
2928
29 /**
30 *
31 */
32 private static final long serialVersionUID = -1838656621043022076L;
33
30 public GameVersionExists() {34 public GameVersionExists() {
31 super();35 super();
32 }36 }
3337
=== modified file 'src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameVersionNotExists.java'
--- src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameVersionNotExists.java 2011-03-20 11:06:48 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameVersionNotExists.java 2011-04-16 12:23:28 +0000
@@ -24,9 +24,13 @@
24/**24/**
25 * Exception used when a given game version does not exist.25 * Exception used when a given game version does not exist.
26 */26 */
27@SuppressWarnings("serial")
28public class GameVersionNotExists extends Exception implements Serializable {27public class GameVersionNotExists extends Exception implements Serializable {
2928
29 /**
30 *
31 */
32 private static final long serialVersionUID = 8443470039286468097L;
33
30 public GameVersionNotExists() {34 public GameVersionNotExists() {
31 super();35 super();
32 }36 }
3337
=== modified file 'src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/PromotedGameExists.java'
--- src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/PromotedGameExists.java 2011-03-16 12:12:34 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/PromotedGameExists.java 2011-04-16 12:23:28 +0000
@@ -24,9 +24,13 @@
24/**24/**
25 * Exception used when a new promoted game is to be created but the promoted game already exists.25 * Exception used when a new promoted game is to be created but the promoted game already exists.
26 */26 */
27@SuppressWarnings("serial")
28public class PromotedGameExists extends Exception implements Serializable{27public class PromotedGameExists extends Exception implements Serializable{
29 28
29 /**
30 *
31 */
32 private static final long serialVersionUID = 8952108432578356503L;
33
30 public PromotedGameExists() {34 public PromotedGameExists() {
31 super();35 super();
32 }36 }
3337
=== modified file 'src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/PromotedGameNotExists.java'
--- src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/PromotedGameNotExists.java 2011-03-16 12:12:34 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/PromotedGameNotExists.java 2011-04-16 12:23:28 +0000
@@ -24,9 +24,13 @@
24/**24/**
25 * Exception used when a given promoted game does not exist.25 * Exception used when a given promoted game does not exist.
26 */26 */
27@SuppressWarnings("serial")
28public class PromotedGameNotExists extends Exception implements Serializable{27public class PromotedGameNotExists extends Exception implements Serializable{
2928
29 /**
30 *
31 */
32 private static final long serialVersionUID = 491619454215655500L;
33
30 public PromotedGameNotExists() {34 public PromotedGameNotExists() {
31 super();35 super();
32 }36 }
3337
=== modified file 'src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/UserExists.java'
--- src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/UserExists.java 2011-03-16 12:12:34 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/UserExists.java 2011-04-16 12:23:28 +0000
@@ -24,9 +24,13 @@
24/**24/**
25 * Exception used when a new user is to be created but the user already exists.25 * Exception used when a new user is to be created but the user already exists.
26 */26 */
27@SuppressWarnings("serial")
28public class UserExists extends Exception implements Serializable{27public class UserExists extends Exception implements Serializable{
29 28
29 /**
30 *
31 */
32 private static final long serialVersionUID = -6023406419592834887L;
33
30 public UserExists() {34 public UserExists() {
31 super();35 super();
32 }36 }
3337
=== added file 'src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/UserGameProfileNotExists.java'
--- src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/UserGameProfileNotExists.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/UserGameProfileNotExists.java 2011-04-16 12:23:28 +0000
@@ -0,0 +1,42 @@
1/* Melbourne University Game-based Learning Environment
2 * Copyright (C) 2011 The University of Melbourne
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18package au.edu.unimelb.csse.mugle.shared.platform.exceptions;
19
20import java.io.Serializable;
21
22import au.edu.unimelb.csse.mugle.shared.model.Game;
23import au.edu.unimelb.csse.mugle.shared.model.User;
24
25public class UserGameProfileNotExists extends Exception implements Serializable {
26 /**
27 *
28 */
29 private static final long serialVersionUID = -6486386063392954899L;
30
31 public UserGameProfileNotExists() {
32 super();
33 }
34
35 public UserGameProfileNotExists(User u, Game g) {
36 super("A UserGameProfile for the User " + u.getUrlName() + " for the game " + g.getUrlName() + " does not exist");
37 }
38
39 public UserGameProfileNotExists(Long primaryKey) {
40 super("A UserGameProfile with the primary key: " + primaryKey + " does not exist.");
41 }
42}
043
=== modified file 'src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/UserNotExists.java'
--- src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/UserNotExists.java 2011-03-16 12:12:34 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/UserNotExists.java 2011-04-16 12:23:28 +0000
@@ -24,9 +24,13 @@
24/**24/**
25 * Exception used when a given user does not exist.25 * Exception used when a given user does not exist.
26 */26 */
27@SuppressWarnings("serial")
28public class UserNotExists extends Exception implements Serializable{27public class UserNotExists extends Exception implements Serializable{
2928
29 /**
30 *
31 */
32 private static final long serialVersionUID = -209272321411054068L;
33
30 public UserNotExists() {34 public UserNotExists() {
31 super();35 super();
32 }36 }
@@ -36,7 +40,7 @@
36 }40 }
37 41
38 public UserNotExists(String urlName) {42 public UserNotExists(String urlName) {
39 super("User + '" + urlName + "' does not exist");43 super("User '" + urlName + "' does not exist");
40 }44 }
41 45
42 public UserNotExists(Long id) {46 public UserNotExists(Long id) {
4347
=== modified file 'src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/UserPrivilegeException.java'
--- src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/UserPrivilegeException.java 2011-03-16 12:12:34 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/UserPrivilegeException.java 2011-04-16 12:23:28 +0000
@@ -23,10 +23,14 @@
23import au.edu.unimelb.csse.mugle.shared.model.User;23import au.edu.unimelb.csse.mugle.shared.model.User;
24import au.edu.unimelb.csse.mugle.shared.model.Role;24import au.edu.unimelb.csse.mugle.shared.model.Role;
2525
26@SuppressWarnings("serial")
27public class UserPrivilegeException extends Exception implements Serializable {26public class UserPrivilegeException extends Exception implements Serializable {
28 27
29 /**28 /**
29 *
30 */
31 private static final long serialVersionUID = 6418600873641304072L;
32
33 /**
30 *34 *
31 * @param u The user that's trying the operation35 * @param u The user that's trying the operation
32 * @param r The required role36 * @param r The required role
3337
=== modified file 'war/WEB-INF/web.xml'
--- war/WEB-INF/web.xml 2011-04-08 09:52:55 +0000
+++ war/WEB-INF/web.xml 2011-04-16 12:23:28 +0000
@@ -4,7 +4,6 @@
4 "http://java.sun.com/dtd/web-app_2_3.dtd">4 "http://java.sun.com/dtd/web-app_2_3.dtd">
55
6<web-app>6<web-app>
7
8 <!-- Default page to serve -->7 <!-- Default page to serve -->
9 <welcome-file-list>8 <welcome-file-list>
10 <welcome-file>Mugle.html</welcome-file>9 <welcome-file>Mugle.html</welcome-file>
@@ -62,7 +61,7 @@
62 <url-pattern>/mugle/users</url-pattern>61 <url-pattern>/mugle/users</url-pattern>
63 </servlet-mapping>62 </servlet-mapping>
64 63
65 <servlet>64 <servlet>
66 <servlet-name>DataService</servlet-name>65 <servlet-name>DataService</servlet-name>
67 <servlet-class>au.edu.unimelb.csse.mugle.server.model.DataServiceImpl</servlet-class>66 <servlet-class>au.edu.unimelb.csse.mugle.server.model.DataServiceImpl</servlet-class>
68 </servlet>67 </servlet>
@@ -81,5 +80,47 @@
81 <servlet-name>FileIOService</servlet-name>80 <servlet-name>FileIOService</servlet-name>
82 <url-pattern>/mugle/files</url-pattern>81 <url-pattern>/mugle/files</url-pattern>
83 </servlet-mapping>82 </servlet-mapping>
83
84 <!-- API servlet mappings -->
85
86 <servlet>
87 <servlet-name>keyValueServlet</servlet-name>
88 <servlet-class>au.edu.unimelb.csse.mugle.server.api.KeyValueServiceImpl</servlet-class>
89 </servlet>
90
91 <servlet-mapping>
92 <servlet-name>keyValueServlet</servlet-name>
93 <url-pattern>/mugle/api-keyvalue</url-pattern>
94 </servlet-mapping>
95
96 <servlet>
97 <servlet-name>UserServlet</servlet-name>
98 <servlet-class>au.edu.unimelb.csse.mugle.server.api.UserServiceImpl</servlet-class>
99 </servlet>
100
101 <servlet-mapping>
102 <servlet-name>UserServlet</servlet-name>
103 <url-pattern>/mugle/api-user</url-pattern>
104 </servlet-mapping>
105
106 <servlet>
107 <servlet-name>HighscoreServlet</servlet-name>
108 <servlet-class>au.edu.unimelb.csse.mugle.server.api.HighscoreServiceImpl</servlet-class>
109 </servlet>
110
111 <servlet-mapping>
112 <servlet-name>HighscoreServlet</servlet-name>
113 <url-pattern>/mugle/api-highscore</url-pattern>
114 </servlet-mapping>
115
116 <servlet>
117 <servlet-name>BadgeServlet</servlet-name>
118 <servlet-class>au.edu.unimelb.csse.mugle.server.api.BadgeServiceImpl</servlet-class>
119 </servlet>
120
121 <servlet-mapping>
122 <servlet-name>BadgeServlet</servlet-name>
123 <url-pattern>/mugle/api-badge</url-pattern>
124 </servlet-mapping>
84125
85</web-app>126</web-app>

Subscribers

People subscribed via source and target branches