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

Proposed by Matt Giuca
Status: Merged
Merged at revision: 102
Proposed branch: lp:~mugle-dev/mugle/ui
Merge into: lp:mugle
Prerequisite: lp:~mugle-dev/mugle/dev-api
Diff against target: 2425 lines (+1111/-329)
46 files modified
src/au/edu/unimelb/csse/mugle/client/ClientService.java (+4/-2)
src/au/edu/unimelb/csse/mugle/client/ClientServiceAsync.java (+1/-1)
src/au/edu/unimelb/csse/mugle/client/Mugle.java (+68/-76)
src/au/edu/unimelb/csse/mugle/client/platform/AdminService.java (+2/-0)
src/au/edu/unimelb/csse/mugle/client/platform/AdminServiceAsync.java (+2/-0)
src/au/edu/unimelb/csse/mugle/client/platform/DeveloperService.java (+3/-1)
src/au/edu/unimelb/csse/mugle/client/platform/DeveloperServiceAsync.java (+2/-0)
src/au/edu/unimelb/csse/mugle/client/platform/GuestService.java (+7/-2)
src/au/edu/unimelb/csse/mugle/client/platform/GuestServiceAsync.java (+5/-2)
src/au/edu/unimelb/csse/mugle/client/ui/MugleDialogBox.java (+104/-0)
src/au/edu/unimelb/csse/mugle/client/ui/MugleUiBuilder.java (+192/-0)
src/au/edu/unimelb/csse/mugle/server/ClientServiceImpl.java (+2/-3)
src/au/edu/unimelb/csse/mugle/server/DataTestServiceImpl.java (+11/-2)
src/au/edu/unimelb/csse/mugle/server/GameFileServer.java (+94/-0)
src/au/edu/unimelb/csse/mugle/server/api/BadgeServiceImpl.java (+0/-2)
src/au/edu/unimelb/csse/mugle/server/api/HighscoreServiceImpl.java (+1/-9)
src/au/edu/unimelb/csse/mugle/server/api/KeyValueServiceImpl.java (+1/-11)
src/au/edu/unimelb/csse/mugle/server/api/UserServiceImpl.java (+2/-18)
src/au/edu/unimelb/csse/mugle/server/model/AchievementGetter.java (+6/-3)
src/au/edu/unimelb/csse/mugle/server/model/DevTeamGetter.java (+6/-4)
src/au/edu/unimelb/csse/mugle/server/model/GameFileData.java (+6/-31)
src/au/edu/unimelb/csse/mugle/server/model/GameFileGetter.java (+116/-0)
src/au/edu/unimelb/csse/mugle/server/model/GameVersionData.java (+7/-33)
src/au/edu/unimelb/csse/mugle/server/model/GameVersionGetter.java (+107/-0)
src/au/edu/unimelb/csse/mugle/server/model/KeyValuePairGetter.java (+13/-9)
src/au/edu/unimelb/csse/mugle/server/model/ModelDataClass.java (+12/-0)
src/au/edu/unimelb/csse/mugle/server/model/ModelWrapper.java (+55/-6)
src/au/edu/unimelb/csse/mugle/server/model/UserAchievementGetter.java (+12/-6)
src/au/edu/unimelb/csse/mugle/server/model/UserGameProfileGetter.java (+13/-7)
src/au/edu/unimelb/csse/mugle/server/model/UserGetter.java (+36/-14)
src/au/edu/unimelb/csse/mugle/server/model/annotations/UserLevel.java (+2/-2)
src/au/edu/unimelb/csse/mugle/server/platform/DeveloperServiceImpl.java (+1/-1)
src/au/edu/unimelb/csse/mugle/server/platform/GuestServiceImpl.java (+14/-2)
src/au/edu/unimelb/csse/mugle/shared/model/DataServiceAsync.java (+1/-1)
src/au/edu/unimelb/csse/mugle/shared/model/GameFile.java (+6/-14)
src/au/edu/unimelb/csse/mugle/shared/model/GameVersion.java (+3/-3)
src/au/edu/unimelb/csse/mugle/shared/model/ModelClass.java (+7/-4)
src/au/edu/unimelb/csse/mugle/shared/model/Role.java (+1/-1)
src/au/edu/unimelb/csse/mugle/shared/model/annotations/MugleDataWrapper.java (+6/-6)
src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameFileNotExists.java (+22/-0)
src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameNotExists.java (+4/-0)
src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/ServerException.java (+34/-0)
war/Mugle.css (+77/-22)
war/Mugle.html (+32/-23)
war/MugleIE6.css (+3/-0)
war/WEB-INF/web.xml (+8/-8)
To merge this branch: bzr merge lp:~mugle-dev/mugle/ui
Reviewer Review Type Date Requested Status
Matt Giuca Approve
Review via email: mp+59455@code.launchpad.net

Description of the change

Adds some new UI capabilities. Merge because it's too hard to separate changes between branches and trunk isn't being worked on anyway.

To post a comment you must log in.
Revision history for this message
Matt Giuca (mgiuca) wrote :

Let's just do it.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== renamed file 'src/au/edu/unimelb/csse/mugle/client/LoginService.java' => 'src/au/edu/unimelb/csse/mugle/client/ClientService.java'
--- src/au/edu/unimelb/csse/mugle/client/LoginService.java 2011-03-06 10:21:39 +0000
+++ src/au/edu/unimelb/csse/mugle/client/ClientService.java 2011-04-29 07:02:27 +0000
@@ -16,10 +16,12 @@
16 */16 */
17package au.edu.unimelb.csse.mugle.client;17package au.edu.unimelb.csse.mugle.client;
1818
19import au.edu.unimelb.csse.mugle.client.LoginInfo;
20
19import com.google.gwt.user.client.rpc.RemoteService;21import com.google.gwt.user.client.rpc.RemoteService;
20import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;22import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
2123
22@RemoteServiceRelativePath("login")24@RemoteServiceRelativePath("client")
23public interface LoginService extends RemoteService {25public interface ClientService extends RemoteService {
24 LoginInfo login(String requestUri);26 LoginInfo login(String requestUri);
25}27}
2628
=== renamed file 'src/au/edu/unimelb/csse/mugle/client/LoginServiceAsync.java' => 'src/au/edu/unimelb/csse/mugle/client/ClientServiceAsync.java'
--- src/au/edu/unimelb/csse/mugle/client/LoginServiceAsync.java 2011-03-06 10:21:39 +0000
+++ src/au/edu/unimelb/csse/mugle/client/ClientServiceAsync.java 2011-04-29 07:02:27 +0000
@@ -18,6 +18,6 @@
1818
19import com.google.gwt.user.client.rpc.AsyncCallback;19import com.google.gwt.user.client.rpc.AsyncCallback;
2020
21public interface LoginServiceAsync {21public interface ClientServiceAsync {
22 void login(String requestUri, AsyncCallback<LoginInfo> async);22 void login(String requestUri, AsyncCallback<LoginInfo> async);
23}23}
2424
=== modified file 'src/au/edu/unimelb/csse/mugle/client/Mugle.java'
--- src/au/edu/unimelb/csse/mugle/client/Mugle.java 2011-04-08 11:51:46 +0000
+++ src/au/edu/unimelb/csse/mugle/client/Mugle.java 2011-04-29 07:02:27 +0000
@@ -1,20 +1,17 @@
1package au.edu.unimelb.csse.mugle.client;1package au.edu.unimelb.csse.mugle.client;
22
3import au.edu.unimelb.csse.mugle.client.ui.MugleUiBuilder;
4
3import com.google.gwt.core.client.EntryPoint;5import com.google.gwt.core.client.EntryPoint;
4import com.google.gwt.core.client.GWT;6import com.google.gwt.core.client.GWT;
5import com.google.gwt.event.logical.shared.ResizeEvent;7import com.google.gwt.user.client.Element;
6import com.google.gwt.event.logical.shared.ResizeHandler;8import com.google.gwt.event.dom.client.ClickEvent;
9import com.google.gwt.event.dom.client.ClickHandler;
7import com.google.gwt.user.client.DOM;10import com.google.gwt.user.client.DOM;
8import com.google.gwt.user.client.Window;
9import com.google.gwt.user.client.rpc.AsyncCallback;11import com.google.gwt.user.client.rpc.AsyncCallback;
12import com.google.gwt.user.client.ui.Button;
10import com.google.gwt.user.client.ui.Grid;13import com.google.gwt.user.client.ui.Grid;
11import com.google.gwt.user.client.ui.HTML;
12import com.google.gwt.user.client.ui.HorizontalPanel;
13import com.google.gwt.user.client.ui.Label;
14import com.google.gwt.user.client.ui.RootPanel;14import com.google.gwt.user.client.ui.RootPanel;
15import com.google.gwt.user.client.ui.StackPanel;
16import com.google.gwt.user.client.ui.VerticalPanel;
17import com.google.gwt.user.client.ui.Widget;
1815
19/**16/**
20 * Entry point classes define <code>onModuleLoad()</code>.17 * Entry point classes define <code>onModuleLoad()</code>.
@@ -27,13 +24,11 @@
27 private static final String SERVER_ERROR = "An error occurred while "24 private static final String SERVER_ERROR = "An error occurred while "
28 + "attempting to contact the server. Please check your network "25 + "attempting to contact the server. Please check your network "
29 + "connection and try again.";26 + "connection and try again.";
3027
31 private final DataTestServiceAsync dataTestService = GWT.create(DataTestService.class);
32
33 private RootPanel mainPanel = null;28 private RootPanel mainPanel = null;
34 29
35 private AuthenticatedUser authUser = new AuthenticatedUser();30 private AuthenticatedUser authUser = new AuthenticatedUser();
3631
37 /**32 /**
38 * This is the entry point method.33 * This is the entry point method.
39 * Checks if logged in, if you are, runs the standard code for page,34 * Checks if logged in, if you are, runs the standard code for page,
@@ -42,11 +37,13 @@
42 @Override37 @Override
43 public void onModuleLoad() {38 public void onModuleLoad() {
44 39
45 this.getStaticPanels();40 this.mainPanel = RootPanel.get("main-panel");
41 Element element = RootPanel.get("error-display").getElement();
42 DOM.removeChild(RootPanel.get("container").getElement(), element);
46 43
47 //Check login status using login service.44 //Check login status using login service.
48 LoginServiceAsync loginService = GWT.create(LoginService.class);45 ClientServiceAsync clientService = GWT.create(ClientService.class);
49 loginService.login(GWT.getHostPageBaseURL(), new AsyncCallback<LoginInfo>() {46 clientService.login(GWT.getHostPageBaseURL(), new AsyncCallback<LoginInfo>() {
50 47
51 public void onFailure(Throwable error) {48 public void onFailure(Throwable error) {
52 System.err.print(error.getMessage());49 System.err.print(error.getMessage());
@@ -61,80 +58,75 @@
61 }); 58 });
6259
63 }60 }
64 61
65 private void getStaticPanels() {
66
67 mainPanel = RootPanel.get("main-panel");
68
69 /*
70 final RootPanel topPanel = RootPanel.get("user-panel");
71 final RootPanel footer = RootPanel.get("footer");
72 final RootPanel errPanel = RootPanel.get("error-display");
73
74 Window.addResizeHandler(new ResizeHandler() {
75 public void onResize(ResizeEvent event) {
76 int h = topPanel.getOffsetHeight() + footer.getOffsetHeight() + errPanel.getOffsetHeight();
77 int height = event.getHeight() - h - 10;
78 if (height < 200) { height = 200; }
79 mainPanel.setHeight(height + "px");
80 }
81 });
82
83 */
84
85 }
86
87 private void arrangeUI() {62 private void arrangeUI() {
88 63
89 if (this.authUser.isLoggedIn()) { 64 if (this.authUser.isLoggedIn()) {
90 65
91 Grid userPanel = new Grid(1,3);66 Grid userPanel = new Grid(1,3);
92 RootPanel.get("user-panel-holder").add(userPanel);67 DOM.getElementById("user-panel-holder").appendChild(userPanel.getElement());
93 68
94 RootPanel mainPanel = RootPanel.get("main-panel");69 //this.mainPanel = RootPanel.get("main-panel");
95 70
96 this.arrangeUserPanel(userPanel);71 MugleUiBuilder.arrangeUserPanel(userPanel, this.authUser);
97 this.arrangeMainPanel(mainPanel);72 MugleUiBuilder.arrangeMainPanel(this.mainPanel);
98 73
99 } else {74 } else {
100 75
101 this.mainPanel.add(this.authUser.resetLoginPanel());76 this.mainPanel.add(this.authUser.resetLoginPanel());
102 77
78
79 // debugging
80
81 //final MugleDialogBox dialog = new MugleDialogBox("Data Population");
82 final Button b = new Button("Populate Data");
83
84 //dialog.setReturnFocus(b);
85
86 b.addStyleName("sendButton");
87 b.addClickHandler(new ClickHandler() {
88
89 DataTestServiceAsync dataTestService = GWT.create(DataTestService.class);
90
91 @Override
92 public void onClick(ClickEvent event) {
93
94 dataTestService.populateDatastore(new AsyncCallback<String>() {
95
96 @Override
97 public void onFailure(Throwable caught) {
98 System.err.println("failed");
99 b.setEnabled(true);
100 b.setText("Try again! Populate Database");
101 //dialog.setBody(new HTML(SERVER_ERROR));
102 //dialog.center();
103 //dialog.show();
104 }
105
106 @Override
107 public void onSuccess(String result) {
108 System.err.println("success");
109 b.setText("Database successfully populated");
110 //dialog.setBody(new HTML(result));
111 //dialog.show();
112 //dialog.center();
113 }
114
115 });
116
117 b.setEnabled(false);
118 b.setText("Processing");
119
120 }
121
122 });
123
124 this.mainPanel.add(b);
125
103 }126 }
104 127
105 }128 }
106 129
107 private void arrangeUserPanel(Grid userPanel) {
108
109 RootPanel.get("user-panel-title").add(new HTML("<b>MUGLE</b>"));
110 userPanel.setWidget(0, 0, new HTML("<b>" + this.authUser.getLoginInfo().getEmailAddress() + "</b>"));
111 userPanel.setWidget(0, 1, new HTML("|"));
112 userPanel.setWidget(0, 2, this.authUser.getSignOutLink());
113
114 }
115
116 private void arrangeMainPanel(RootPanel mainPanel) {
117
118 HorizontalPanel hp = new HorizontalPanel();
119
120 // left panel
121 StackPanel sp = new StackPanel();
122 //sp.setWidth("200px");
123 DOM.setElementAttribute(sp.getElement(), "id", "tools-panel");
124
125
126 sp.setStackText(0, "Topic", false);
127
128 sp.insert(new HTML("test"), 0);
129 sp.insert(new HTML("test 2"), 1);
130 sp.insert(new HTML("test 3"), 2);
131
132 hp.insert(sp, 0);
133 hp.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT);
134 mainPanel.add(hp);
135
136 }
137
138/*130/*
139 private void loadDataTest() {131 private void loadDataTest() {
140 //Set up sign out hyperlink.132 //Set up sign out hyperlink.
141133
=== modified file 'src/au/edu/unimelb/csse/mugle/client/platform/AdminService.java'
--- src/au/edu/unimelb/csse/mugle/client/platform/AdminService.java 2011-03-20 11:06:48 +0000
+++ src/au/edu/unimelb/csse/mugle/client/platform/AdminService.java 2011-04-29 07:02:27 +0000
@@ -41,6 +41,8 @@
41 41
42 boolean banUser(Long id) throws UserNotExists, UserPrivilegeException;42 boolean banUser(Long id) throws UserNotExists, UserPrivilegeException;
4343
44 User getCurrentUserDetails() throws ServerException;
45
44 // DevTeams46 // DevTeams
4547
46 DevTeam addNewDevTeam(DevTeam devTeam) throws DevTeamExists, UserPrivilegeException;48 DevTeam addNewDevTeam(DevTeam devTeam) throws DevTeamExists, UserPrivilegeException;
4749
=== modified file 'src/au/edu/unimelb/csse/mugle/client/platform/AdminServiceAsync.java'
--- src/au/edu/unimelb/csse/mugle/client/platform/AdminServiceAsync.java 2011-03-20 11:06:48 +0000
+++ src/au/edu/unimelb/csse/mugle/client/platform/AdminServiceAsync.java 2011-04-29 07:02:27 +0000
@@ -100,5 +100,7 @@
100100
101 void demoteGame(String promotedGameKey,101 void demoteGame(String promotedGameKey,
102 AsyncCallback<GameVersion> callback);102 AsyncCallback<GameVersion> callback);
103
104 void getCurrentUserDetails(AsyncCallback<User> callback);
103 105
104}106}
105107
=== modified file 'src/au/edu/unimelb/csse/mugle/client/platform/DeveloperService.java'
--- src/au/edu/unimelb/csse/mugle/client/platform/DeveloperService.java 2011-03-20 11:06:48 +0000
+++ src/au/edu/unimelb/csse/mugle/client/platform/DeveloperService.java 2011-04-29 07:02:27 +0000
@@ -21,12 +21,13 @@
21import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameNotExists;21import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameNotExists;
22import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameVersionExists;22import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameVersionExists;
23import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameVersionNotExists;23import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameVersionNotExists;
24import au.edu.unimelb.csse.mugle.shared.platform.exceptions.ServerException;
24import au.edu.unimelb.csse.mugle.shared.platform.exceptions.UserPrivilegeException;25import au.edu.unimelb.csse.mugle.shared.platform.exceptions.UserPrivilegeException;
2526
26import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;27import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
2728
28@RemoteServiceRelativePath("dev")29@RemoteServiceRelativePath("dev")
29public interface DeveloperService extends UserService {30public interface DeveloperService extends GuestService {
3031
31 GameVersion addGameVersion(GameVersion gameVersion) throws GameVersionExists, GameNotExists, UserPrivilegeException;32 GameVersion addGameVersion(GameVersion gameVersion) throws GameVersionExists, GameNotExists, UserPrivilegeException;
3233
@@ -38,4 +39,5 @@
38 39
39 boolean removeGameVersion(Long pKey) throws GameVersionNotExists, UserPrivilegeException;40 boolean removeGameVersion(Long pKey) throws GameVersionNotExists, UserPrivilegeException;
40 41
42 User getCurrentUserDetails() throws ServerException;
41}43}
4244
=== modified file 'src/au/edu/unimelb/csse/mugle/client/platform/DeveloperServiceAsync.java'
--- src/au/edu/unimelb/csse/mugle/client/platform/DeveloperServiceAsync.java 2011-03-20 11:06:48 +0000
+++ src/au/edu/unimelb/csse/mugle/client/platform/DeveloperServiceAsync.java 2011-04-29 07:02:27 +0000
@@ -42,4 +42,6 @@
4242
43 void removeGameVersion(Long pKey, AsyncCallback<Boolean> callback);43 void removeGameVersion(Long pKey, AsyncCallback<Boolean> callback);
4444
45 void getCurrentUserDetails(AsyncCallback<User> callback);
46
45}47}
4648
=== renamed file 'src/au/edu/unimelb/csse/mugle/client/platform/UserService.java' => 'src/au/edu/unimelb/csse/mugle/client/platform/GuestService.java'
--- src/au/edu/unimelb/csse/mugle/client/platform/UserService.java 2011-03-09 08:55:08 +0000
+++ src/au/edu/unimelb/csse/mugle/client/platform/GuestService.java 2011-04-29 07:02:27 +0000
@@ -17,10 +17,15 @@
1717
18package au.edu.unimelb.csse.mugle.client.platform;18package au.edu.unimelb.csse.mugle.client.platform;
1919
20import au.edu.unimelb.csse.mugle.shared.model.User;
21import au.edu.unimelb.csse.mugle.shared.platform.exceptions.ServerException;
22
20import com.google.gwt.user.client.rpc.RemoteService;23import com.google.gwt.user.client.rpc.RemoteService;
21import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;24import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
2225
23@RemoteServiceRelativePath("users")26@RemoteServiceRelativePath("guests")
24public interface UserService extends RemoteService {27public interface GuestService extends RemoteService {
2528
29 User getCurrentUserDetails() throws ServerException;
30
26}31}
2732
=== renamed file 'src/au/edu/unimelb/csse/mugle/client/platform/UserServiceAsync.java' => 'src/au/edu/unimelb/csse/mugle/client/platform/GuestServiceAsync.java'
--- src/au/edu/unimelb/csse/mugle/client/platform/UserServiceAsync.java 2011-03-10 04:50:07 +0000
+++ src/au/edu/unimelb/csse/mugle/client/platform/GuestServiceAsync.java 2011-04-29 07:02:27 +0000
@@ -19,10 +19,13 @@
1919
20import com.google.gwt.user.client.rpc.AsyncCallback;20import com.google.gwt.user.client.rpc.AsyncCallback;
2121
22import au.edu.unimelb.csse.mugle.shared.model.User;
23
22/**24/**
23 * The async counterpart of <code>UserService</code>.25 * The async counterpart of <code>GuestService</code>.
24 */26 */
25public interface UserServiceAsync {27public interface GuestServiceAsync {
2628
29 void getCurrentUserDetails(AsyncCallback<User> callback);
2730
28}31}
2932
=== added file 'src/au/edu/unimelb/csse/mugle/client/ui/MugleDialogBox.java'
--- src/au/edu/unimelb/csse/mugle/client/ui/MugleDialogBox.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/client/ui/MugleDialogBox.java 2011-04-29 07:02:27 +0000
@@ -0,0 +1,104 @@
1package au.edu.unimelb.csse.mugle.client.ui;
2
3import com.google.gwt.event.dom.client.ClickEvent;
4import com.google.gwt.event.dom.client.ClickHandler;
5import com.google.gwt.user.client.ui.Button;
6import com.google.gwt.user.client.ui.DialogBox;
7import com.google.gwt.user.client.ui.FocusWidget;
8import com.google.gwt.user.client.ui.HTML;
9import com.google.gwt.user.client.ui.HorizontalPanel;
10import com.google.gwt.user.client.ui.VerticalPanel;
11
12public class MugleDialogBox extends DialogBox {
13
14 private final Button closeButton = new Button("Close");
15 private final HorizontalPanel bodyHolder = new HorizontalPanel();
16
17 private FocusWidget returnFocus = null;
18 private HTML body = new HTML();
19
20 public MugleDialogBox(String text, HTML body, FocusWidget focus) {
21 super(false);
22 this.returnFocus = focus;
23 this.setText(text);
24 this.setup();
25 this.setBody(body);
26 }
27
28 public MugleDialogBox(String text) {
29 super(false);
30 this.setText(text);
31 this.setup();
32 }
33
34 public MugleDialogBox() {
35 super(false);
36 this.setup();
37 }
38
39 private void setup() {
40
41 this.setAnimationEnabled(true);
42
43 this.closeButton.getElement().setId("closeButton");
44 VerticalPanel dialogVPanel = new VerticalPanel();
45 dialogVPanel.addStyleName("dialogVPanel");
46 dialogVPanel.add(bodyHolder);
47 dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
48 dialogVPanel.add(closeButton);
49 this.setWidget(dialogVPanel);
50
51 // Add a handler to close the DialogBox
52 closeButton.addClickHandler(new DialogClickHandler(this));
53
54 }
55
56 public void show() {
57 this.center();
58 this.closeButton.setFocus(true);
59 }
60
61 protected Button getCloseButton() {
62 return this.closeButton;
63 }
64
65 protected FocusWidget getReturnFocus() {
66 return this.returnFocus;
67 }
68
69 public HTML getBody() {
70 return this.body;
71 }
72
73 public void setBody(HTML body) {
74 this.body = body;
75 if (body != null) {
76 this.bodyHolder.clear();
77 this.bodyHolder.add(body);
78 }
79 }
80
81 public void setReturnFocus(FocusWidget returnFocus) {
82 this.returnFocus = returnFocus;
83 }
84
85 private class DialogClickHandler implements ClickHandler {
86
87 MugleDialogBox mdb = null;
88
89 public DialogClickHandler(MugleDialogBox mdb) {
90 this.mdb = mdb;
91 }
92
93 @Override
94 public void onClick(ClickEvent event) {
95 this.mdb.hide();
96 if (this.mdb.getReturnFocus() != null) {
97 this.mdb.getReturnFocus().setEnabled(true);
98 this.mdb.getReturnFocus().setFocus(true);
99 }
100 }
101
102 }
103
104}
0105
=== modified file 'src/au/edu/unimelb/csse/mugle/client/ui/MugleUiBuilder.java'
--- src/au/edu/unimelb/csse/mugle/client/ui/MugleUiBuilder.java 2011-04-29 07:02:27 +0000
+++ src/au/edu/unimelb/csse/mugle/client/ui/MugleUiBuilder.java 2011-04-29 07:02:27 +0000
@@ -3,17 +3,38 @@
3import java.util.Collection;3import java.util.Collection;
4import java.util.Iterator;4import java.util.Iterator;
55
6import au.edu.unimelb.csse.mugle.client.AuthenticatedUser;
7import au.edu.unimelb.csse.mugle.client.platform.GuestService;
8import au.edu.unimelb.csse.mugle.client.platform.GuestServiceAsync;
9import au.edu.unimelb.csse.mugle.shared.model.Role;
10import au.edu.unimelb.csse.mugle.shared.model.User;
11
12import com.google.gwt.core.client.GWT;
13import com.google.gwt.dom.client.Style;
14import com.google.gwt.dom.client.Style.Overflow;
15import com.google.gwt.dom.client.Style.Unit;
6import com.google.gwt.event.dom.client.ClickHandler;16import com.google.gwt.event.dom.client.ClickHandler;
17import com.google.gwt.user.client.DOM;
18import com.google.gwt.user.client.rpc.AsyncCallback;
19import com.google.gwt.user.client.ui.AbsolutePanel;
20import com.google.gwt.user.client.ui.Anchor;
7import com.google.gwt.user.client.ui.Button;21import com.google.gwt.user.client.ui.Button;
8import com.google.gwt.user.client.ui.CellPanel;22import com.google.gwt.user.client.ui.CellPanel;
23import com.google.gwt.user.client.ui.DockLayoutPanel;
9import com.google.gwt.user.client.ui.FlexTable;24import com.google.gwt.user.client.ui.FlexTable;
25import com.google.gwt.user.client.ui.Grid;
26import com.google.gwt.user.client.ui.HTML;
10import com.google.gwt.user.client.ui.HorizontalPanel;27import com.google.gwt.user.client.ui.HorizontalPanel;
11import com.google.gwt.user.client.ui.Label;28import com.google.gwt.user.client.ui.Label;
29import com.google.gwt.user.client.ui.RootPanel;
30import com.google.gwt.user.client.ui.StackPanel;
12import com.google.gwt.user.client.ui.VerticalPanel;31import com.google.gwt.user.client.ui.VerticalPanel;
13import com.google.gwt.user.client.ui.Widget;32import com.google.gwt.user.client.ui.Widget;
1433
15public class MugleUiBuilder {34public class MugleUiBuilder {
16 35
36 private static GuestServiceAsync guestService = GWT.create(GuestService.class);
37
17 private MugleUiBuilder() { }38 private MugleUiBuilder() { }
18 39
19 public static CellPanel buildStringTable(Collection<Collection<String>> list, Collection<String> headers) {40 public static CellPanel buildStringTable(Collection<Collection<String>> list, Collection<String> headers) {
@@ -140,5 +161,176 @@
140 if (handler != null) { b.addClickHandler(handler); }161 if (handler != null) { b.addClickHandler(handler); }
141 panel.add(b); 162 panel.add(b);
142 }163 }
164
165 public static <T extends Widget> T setId(T w, String id) {
166 w.getElement().setId(id);
167 return w;
168 }
169
170 public static void arrangeUserPanel(Grid userPanel, AuthenticatedUser authuser) {
171
172 DOM.getElementById("user-panel-title").appendChild((new HTML("<b>MUGLE</b>")).getElement());
173 userPanel.setWidget(0, 0, new HTML("<b>" + authuser.getLoginInfo().getEmailAddress() + "</b>"));
174 userPanel.setWidget(0, 1, new HTML("|"));
175 userPanel.setWidget(0, 2, authuser.getSignOutLink());
176
177 }
178
179 public static void arrangeMainPanel(RootPanel mainPanel) {
180
181 AbsolutePanel container = setId(new AbsolutePanel(), "main-panel-container");
182 mainPanel.add(container);
183
184 AbsolutePanel inner = setId(new AbsolutePanel(), "main-panel-container-inner");
185 inner.getElement().getStyle().setOverflow(Overflow.VISIBLE);
186 container.add(inner);
187
188 AbsolutePanel tp = setId(new AbsolutePanel(), "tools-panel");
189 AbsolutePanel rp = setId(new AbsolutePanel(), "right-panel");
190 AbsolutePanel rpi = setId(new AbsolutePanel(), "right-panel-inner");
191
192 tp.add(buildToolsPanel());
193 rpi.add(buildRightPanel());
194 rp.add(rpi);
195
196 inner.add(tp);
197 inner.add(rp);
198
199 }
200
201 private static Widget buildToolsPanel() {
202
203 // left panel
204 final StackPanel sp = new StackPanel();
205 sp.setWidth("100%");
206 sp.getElement().getStyle().setFontSize(1, Unit.EM);
207
208 System.out.println("test1");
209
210 guestService.getCurrentUserDetails(new AsyncCallback<User>() {
211
212 @Override
213 public void onSuccess(User result) {
214
215 System.out.println("success");
216
217 Widget tmp = null;
218 if ((tmp = buildMyMugle(result)) != null) {
219 sp.add(tmp, "My Mugle", false);
220 }
221 if ((tmp = buildMuglePublic(result)) != null) {
222 sp.add(tmp, "Mugle Public", false);
223 }
224 if ((tmp = buildSettings(result)) != null) {
225 sp.add(tmp, "Settings", false);
226 }
227 if ((tmp = buildAdmin(result)) != null) {
228 sp.add(tmp, "Admin", false);
229 }
230
231 }
232
233 @Override
234 public void onFailure(Throwable caught) {
235
236 // TODO Auto-generated method stub
237 System.out.println("fail");
238
239 }
240
241 });
242
243 return sp;
244
245 }
246
247 private static Widget buildMyMugle(User user) {
248
249 Role role = user.getRole();
250
251 switch (role) {
252
253 case ADMIN:
254 case DEVELOPER:
255
256 VerticalPanel vp = new VerticalPanel();
257 vp.add(new Anchor("Promoted Games"));
258 vp.add(new Anchor("Games Gallery"));
259 vp.add(new Anchor("Promoted Games"));
260 return vp;
261
262 }
263
264 return null;
265
266 }
143267
268 private static Widget buildMuglePublic(User user) {
269
270 VerticalPanel vp = new VerticalPanel();
271
272 vp.add(new Anchor("Promoted Games"));
273 vp.add(new Anchor("Games Gallery"));
274
275 return vp;
276
277 }
278
279 private static Widget buildSettings(User user) {
280
281 VerticalPanel vp = new VerticalPanel();
282
283 vp.add(new Anchor("Settings 1"));
284 vp.add(new Anchor("Settings 2"));
285
286 return vp;
287
288 }
289
290 private static Widget buildAdmin(User user) {
291
292 Role role = user.getRole();
293
294 switch (role) {
295
296 case ADMIN:
297
298 VerticalPanel vp = new VerticalPanel();
299 vp.add(new Anchor("Promoted Games"));
300 vp.add(new Anchor("Games Gallery"));
301 vp.add(new Anchor("Promoted Games"));
302 return vp;
303
304 }
305
306 return null;
307
308 }
309
310 private static Widget buildRightPanel() {
311
312 final HorizontalPanel panel = new HorizontalPanel();
313
314 panel.add(new HTML("Under Construction!"));
315
316 // debug
317 GuestServiceAsync us = GWT.create(GuestService.class);
318 us.getCurrentUserDetails(new AsyncCallback<User>() {
319
320 @Override
321 public void onSuccess(User result) {
322 panel.add(new HTML("NAME: "+result.getFullName()));
323 }
324
325 @Override
326 public void onFailure(Throwable caught) {
327 panel.add(new HTML("FAILED!"));
328 }
329
330 });
331
332 return panel;
333
334 }
335
144}336}
145337
=== renamed file 'src/au/edu/unimelb/csse/mugle/server/LoginServiceImpl.java' => 'src/au/edu/unimelb/csse/mugle/server/ClientServiceImpl.java'
--- src/au/edu/unimelb/csse/mugle/server/LoginServiceImpl.java 2011-04-29 07:02:27 +0000
+++ src/au/edu/unimelb/csse/mugle/server/ClientServiceImpl.java 2011-04-29 07:02:27 +0000
@@ -20,12 +20,11 @@
20import com.google.appengine.api.users.UserService;20import com.google.appengine.api.users.UserService;
21import com.google.appengine.api.users.UserServiceFactory;21import com.google.appengine.api.users.UserServiceFactory;
22import au.edu.unimelb.csse.mugle.client.LoginInfo;22import au.edu.unimelb.csse.mugle.client.LoginInfo;
23import au.edu.unimelb.csse.mugle.client.LoginService;23import au.edu.unimelb.csse.mugle.client.ClientService;
24import com.google.gwt.user.server.rpc.RemoteServiceServlet;24import com.google.gwt.user.server.rpc.RemoteServiceServlet;
2525
26@SuppressWarnings("serial")26@SuppressWarnings("serial")
27public class LoginServiceImpl extends RemoteServiceServlet implements27public class ClientServiceImpl extends RemoteServiceServlet implements ClientService {
28 LoginService {
2928
30 public LoginInfo login(String requestUri) {29 public LoginInfo login(String requestUri) {
31 UserService userService = UserServiceFactory.getUserService();30 UserService userService = UserServiceFactory.getUserService();
3231
=== modified file 'src/au/edu/unimelb/csse/mugle/server/DataTestServiceImpl.java'
--- src/au/edu/unimelb/csse/mugle/server/DataTestServiceImpl.java 2011-04-29 07:02:27 +0000
+++ src/au/edu/unimelb/csse/mugle/server/DataTestServiceImpl.java 2011-04-29 07:02:27 +0000
@@ -31,26 +31,35 @@
31 31
32 PersistenceManager pm = PMF.getManager();32 PersistenceManager pm = PMF.getManager();
3333
34 System.err.println("test1");
35
34 if (pm == null) {36 if (pm == null) {
35 return "Datastore populating failed!";37 return "Datastore populating failed!";
36 }38 }
3739
40 System.err.println("test2");
41
38 UserData[] users = new UserData[] { 42 UserData[] users = new UserData[] {
39 new UserData("~matt", "Matt Giuca", "matt@test.com", Role.ADMIN),43 new UserData("~matt", "Matt Giuca", "matt@test.com", Role.ADMIN),
40 new UserData("~scott", "Scott Ritchie", "scott@test.com", Role.ADMIN),44 new UserData("~scott", "Scott Ritchie", "scott@test.com", Role.ADMIN),
41 new UserData("~prageeth", "Prageeth Silva", "prageeth@test.com", Role.ADMIN),45 new UserData("~prageeth", "Prageeth Silva", "prageeth@test.com", Role.ADMIN),
42 new UserData("~bob", "Bob", "bob@test.com", Role.DEVELOPER),46 new UserData("~bob", "Bob", "bob@test.com", Role.DEVELOPER),
43 new UserData("~jim", "Jim", "jim@test.com", Role.DEVELOPER),47 new UserData("~jim", "Jim", "jim@test.com", Role.DEVELOPER),
44 new UserData("~john", "John", "john@test.com", Role.USER),48 new UserData("~john", "John", "john@test.com", Role.GUEST),
45 new UserData("~admin", "Admin", "admin@test.com", Role.ADMIN),49 new UserData("~admin", "Admin", "admin@test.com", Role.ADMIN),
46 new UserData("~dev", "Dev", "dev@test.com", Role.DEVELOPER)50 new UserData("~dev", "Dev", "dev@test.com", Role.DEVELOPER),
51 new UserData("~test", "Test", "test@example.com", Role.DEVELOPER)
47 };52 };
48 53
54 System.err.println("test3");
55
49 pm.makePersistentAll(users);56 pm.makePersistentAll(users);
50 pm.makePersistent(users[0]);57 pm.makePersistent(users[0]);
51 pm.flush();58 pm.flush();
52 pm.close();59 pm.close();
53 60
61 System.err.println("test4");
62
54 return "Data addition succeful!";63 return "Data addition succeful!";
5564
56 }65 }
5766
=== added file 'src/au/edu/unimelb/csse/mugle/server/GameFileServer.java'
--- src/au/edu/unimelb/csse/mugle/server/GameFileServer.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/server/GameFileServer.java 2011-04-29 07:02:27 +0000
@@ -0,0 +1,94 @@
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;
18
19import java.io.IOException;
20import java.util.Map;
21import java.util.Map.Entry;
22
23import javax.servlet.ServletException;
24import javax.servlet.http.HttpServlet;
25import javax.servlet.http.HttpServletRequest;
26import javax.servlet.http.HttpServletResponse;
27
28import au.edu.unimelb.csse.mugle.server.model.GameFileData;
29import au.edu.unimelb.csse.mugle.server.model.GameFileGetter;
30import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameFileNotExists;
31import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameNotExists;
32import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameVersionNotExists;
33
34import com.google.appengine.api.blobstore.BlobKey;
35import com.google.appengine.api.blobstore.BlobstoreService;
36import com.google.appengine.api.blobstore.BlobstoreServiceFactory;
37
38@SuppressWarnings("serial")
39public class GameFileServer extends HttpServlet {
40
41 public void doGet(HttpServletRequest req, HttpServletResponse res)
42 throws IOException {
43 BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
44
45 try {
46 BlobKey blobKey = getBlobKey(req);
47 blobstoreService.serve(blobKey, res);
48 } catch (GameFileNotExists e) {
49 //TODO: Construct a page with the error
50 }
51 }
52
53 private BlobKey getBlobKey(HttpServletRequest req)
54 throws GameFileNotExists {
55 GameFileGetter gfg = new GameFileGetter();
56 String gameName = null;
57 String gameVersion = null;
58 String path = null;
59
60 /* We need to parse the request to get the gameName, gameVersion
61 * and path,
62 * URLs are in the form /game/gameName/gameVersion/path
63 */
64 String toParse = req.getRequestURI().split("/game/")[1]; // gets everything after /game/ in the URI
65 String[] splitted = toParse.split("/");
66 gameName = splitted[0];
67 gameVersion = splitted[1];
68 path = toParse.split(gameVersion)[1];
69
70 try {
71 GameFileData file = gfg.getGameFile(gameName, gameVersion, path);
72 return file.getBlobKey();
73 } catch (GameNotExists e) {
74 throw new GameFileNotExists(gameName, gameVersion, path);
75 } catch (GameVersionNotExists e) {
76 throw new GameFileNotExists(gameName, gameVersion, path);
77 }
78 }
79
80 /*
81 public void doPost(HttpServletRequest req, HttpServletResponse res)
82 throws ServletException, IOException{
83 BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
84
85 Map<String, BlobKey> blobs = blobstoreService.getUploadedBlobs(req);
86 /* We want to iterate over each of the blobs, and create the
87 * appropriate datastore classes
88 *
89 for(Entry<String, BlobKey> blobEntry : blobs.entrySet()){
90
91 }
92
93 } */
94}
095
=== modified file 'src/au/edu/unimelb/csse/mugle/server/api/BadgeServiceImpl.java'
--- src/au/edu/unimelb/csse/mugle/server/api/BadgeServiceImpl.java 2011-04-29 07:02:27 +0000
+++ src/au/edu/unimelb/csse/mugle/server/api/BadgeServiceImpl.java 2011-04-29 07:02:27 +0000
@@ -58,8 +58,6 @@
58 UserAchievementGetter u = new UserAchievementGetter();58 UserAchievementGetter u = new UserAchievementGetter();
59 try {59 try {
60 return u.getUserAchievement(pm, name, gameToken);60 return u.getUserAchievement(pm, name, gameToken);
61 } catch (UserNotExists e) {
62 throw new Error(e);
63 } catch (AchievementNotExists e) {61 } catch (AchievementNotExists e) {
64 throw new BadgeError(e.getMessage());62 throw new BadgeError(e.getMessage());
65 }63 }
6664
=== modified file 'src/au/edu/unimelb/csse/mugle/server/api/HighscoreServiceImpl.java'
--- src/au/edu/unimelb/csse/mugle/server/api/HighscoreServiceImpl.java 2011-04-29 07:02:27 +0000
+++ src/au/edu/unimelb/csse/mugle/server/api/HighscoreServiceImpl.java 2011-04-29 07:02:27 +0000
@@ -22,8 +22,6 @@
22import au.edu.unimelb.csse.mugle.server.model.UserGameProfileGetter;22import au.edu.unimelb.csse.mugle.server.model.UserGameProfileGetter;
23import au.edu.unimelb.csse.mugle.shared.api.GameTokenError;23import au.edu.unimelb.csse.mugle.shared.api.GameTokenError;
24import au.edu.unimelb.csse.mugle.server.model.UserGameProfileData;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;25import com.google.gwt.user.server.rpc.RemoteServiceServlet;
2826
29import javax.jdo.PersistenceManager;27import javax.jdo.PersistenceManager;
@@ -40,11 +38,7 @@
40 public int getHighScore(String gameToken) throws GameTokenError {38 public int getHighScore(String gameToken) throws GameTokenError {
41 UserGameProfileGetter u = new UserGameProfileGetter();39 UserGameProfileGetter u = new UserGameProfileGetter();
42 UserGameProfileData ugp;40 UserGameProfileData ugp;
43 try {41 ugp = u.getCurrentUserGameProfile(gameToken);
44 ugp = u.getCurrentUserGameProfile(gameToken);
45 } catch (UserNotExists e) {
46 throw new Error(e);
47 }
48 return ugp.getHighscore();42 return ugp.getHighscore();
49 }43 }
5044
@@ -56,8 +50,6 @@
56 ugp = u.getCurrentUserGameProfile(pm, gameToken);50 ugp = u.getCurrentUserGameProfile(pm, gameToken);
57 if (score > ugp.getHighscore())51 if (score > ugp.getHighscore())
58 ugp.setHighscore(score);52 ugp.setHighscore(score);
59 } catch (UserNotExists e) {
60 throw new Error(e);
61 } finally {53 } finally {
62 pm.close();54 pm.close();
63 }55 }
6456
=== modified file 'src/au/edu/unimelb/csse/mugle/server/api/KeyValueServiceImpl.java'
--- src/au/edu/unimelb/csse/mugle/server/api/KeyValueServiceImpl.java 2011-04-29 07:02:27 +0000
+++ src/au/edu/unimelb/csse/mugle/server/api/KeyValueServiceImpl.java 2011-04-29 07:02:27 +0000
@@ -25,8 +25,6 @@
25import au.edu.unimelb.csse.mugle.shared.api.GameTokenError;25import au.edu.unimelb.csse.mugle.shared.api.GameTokenError;
26import au.edu.unimelb.csse.mugle.shared.api.KeyError;26import au.edu.unimelb.csse.mugle.shared.api.KeyError;
27import au.edu.unimelb.csse.mugle.server.model.KeyValuePairData;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;28import com.google.gwt.user.server.rpc.RemoteServiceServlet;
3129
32import javax.jdo.PersistenceManager;30import javax.jdo.PersistenceManager;
@@ -48,8 +46,6 @@
48 try {46 try {
49 kvp = k.getKeyValuePair(pm, key, gameToken, true);47 kvp = k.getKeyValuePair(pm, key, gameToken, true);
50 kvp.setValue(value);48 kvp.setValue(value);
51 } catch (UserNotExists e) {
52 throw new Error(e);
53 } catch (KeyError e) {49 } catch (KeyError e) {
54 // XXX This should never happen (since we are using createIfNotFound=true)50 // XXX This should never happen (since we are using createIfNotFound=true)
55 throw new Error(e);51 throw new Error(e);
@@ -63,11 +59,7 @@
63 {59 {
64 KeyValuePairGetter k = new KeyValuePairGetter();60 KeyValuePairGetter k = new KeyValuePairGetter();
65 KeyValuePairData kvp;61 KeyValuePairData kvp;
66 try {62 kvp = k.getKeyValuePair(key, gameToken);
67 kvp = k.getKeyValuePair(key, gameToken);
68 } catch (UserNotExists e) {
69 throw new Error(e);
70 }
71 return (Serializable) kvp.getValue();63 return (Serializable) kvp.getValue();
72 }64 }
7365
@@ -77,8 +69,6 @@
77 KeyValuePairGetter k = new KeyValuePairGetter();69 KeyValuePairGetter k = new KeyValuePairGetter();
78 try {70 try {
79 k.getKeyValuePair(key, gameToken);71 k.getKeyValuePair(key, gameToken);
80 } catch (UserNotExists e) {
81 throw new Error(e);
82 } catch (KeyError e) {72 } catch (KeyError e) {
83 return false;73 return false;
84 }74 }
8575
=== modified file 'src/au/edu/unimelb/csse/mugle/server/api/UserServiceImpl.java'
--- src/au/edu/unimelb/csse/mugle/server/api/UserServiceImpl.java 2011-04-29 07:02:27 +0000
+++ src/au/edu/unimelb/csse/mugle/server/api/UserServiceImpl.java 2011-04-29 07:02:27 +0000
@@ -19,8 +19,6 @@
1919
20import au.edu.unimelb.csse.mugle.client.api.UserService;20import au.edu.unimelb.csse.mugle.client.api.UserService;
21import au.edu.unimelb.csse.mugle.server.model.UserGetter;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;22import com.google.gwt.user.server.rpc.RemoteServiceServlet;
2523
2624
@@ -34,25 +32,11 @@
3432
35 public String getUserNickName() {33 public String getUserNickName() {
36 UserGetter u = new UserGetter();34 UserGetter u = new UserGetter();
37 try35 return u.getCurrentUser().getUrlName();
38 {
39 return u.getCurrentUser().getUrlName();
40 }
41 catch (UserNotExists e)
42 {
43 throw new Error(e);
44 }
45 }36 }
46 37
47 public String getUserID() {38 public String getUserID() {
48 UserGetter u = new UserGetter();39 UserGetter u = new UserGetter();
49 try40 return u.getCurrentUser().getGoogleID();
50 {
51 return u.getCurrentUser().getGoogleID();
52 }
53 catch (UserNotExists e)
54 {
55 throw new Error(e);
56 }
57 }41 }
58}42}
5943
=== modified file 'src/au/edu/unimelb/csse/mugle/server/model/AchievementGetter.java'
--- src/au/edu/unimelb/csse/mugle/server/model/AchievementGetter.java 2011-04-29 07:02:27 +0000
+++ src/au/edu/unimelb/csse/mugle/server/model/AchievementGetter.java 2011-04-29 07:02:27 +0000
@@ -17,6 +17,8 @@
1717
18package au.edu.unimelb.csse.mugle.server.model;18package au.edu.unimelb.csse.mugle.server.model;
1919
20import java.util.List;
21
20import javax.jdo.PersistenceManager;22import javax.jdo.PersistenceManager;
21import javax.jdo.Query;23import javax.jdo.Query;
2224
@@ -54,6 +56,7 @@
54 * @throws GameTokenError56 * @throws GameTokenError
55 * @throws AchievementNotExists57 * @throws AchievementNotExists
56 */58 */
59 @SuppressWarnings("unchecked")
57 public AchievementData getAchievement(PersistenceManager pm, String name, String gameToken) 60 public AchievementData getAchievement(PersistenceManager pm, String name, String gameToken)
58 throws GameTokenError, AchievementNotExists {61 throws GameTokenError, AchievementNotExists {
59 GameGetter g = new GameGetter();62 GameGetter g = new GameGetter();
@@ -61,13 +64,13 @@
61 64
62 Query q = pm.newQuery(AchievementData.class, "game == g && name == n");65 Query q = pm.newQuery(AchievementData.class, "game == g && name == n");
63 q.declareParameters("GameData g, String n");66 q.declareParameters("GameData g, String n");
64 AchievementData achievement = (AchievementData) q.execute(curGame, name);67 List<AchievementData> results = (List<AchievementData>) q.execute(curGame, name);
6568
66 if (achievement == null) {69 if (results.isEmpty()) {
67 throw new AchievementNotExists(curGame.getUrlName(), name);70 throw new AchievementNotExists(curGame.getUrlName(), name);
68 }71 }
69 72
70 return achievement;73 return results.get(0);
71 }74 }
7275
73 /**76 /**
7477
=== modified file 'src/au/edu/unimelb/csse/mugle/server/model/DevTeamGetter.java'
--- src/au/edu/unimelb/csse/mugle/server/model/DevTeamGetter.java 2011-04-29 07:02:27 +0000
+++ src/au/edu/unimelb/csse/mugle/server/model/DevTeamGetter.java 2011-04-29 07:02:27 +0000
@@ -1,5 +1,7 @@
1package au.edu.unimelb.csse.mugle.server.model;1package au.edu.unimelb.csse.mugle.server.model;
22
3import java.util.List;
4
3import javax.jdo.PersistenceManager;5import javax.jdo.PersistenceManager;
4import javax.jdo.Query;6import javax.jdo.Query;
57
@@ -31,17 +33,17 @@
31 * @return The DevTeamData33 * @return The DevTeamData
32 * @throws DevTeamDataNotExists34 * @throws DevTeamDataNotExists
33 */35 */
36 @SuppressWarnings("unchecked")
34 public DevTeamData getDevTeam(PersistenceManager pm, String name) throws DevTeamNotExists {37 public DevTeamData getDevTeam(PersistenceManager pm, String name) throws DevTeamNotExists {
35 DevTeamData devTeam= null;
36 Query q = pm.newQuery(DevTeamData.class, "urlName == u");38 Query q = pm.newQuery(DevTeamData.class, "urlName == u");
37 q.declareParameters("String u");39 q.declareParameters("String u");
38 devTeam = (DevTeamData) q.execute(name);40 List<DevTeamData> results = (List<DevTeamData>) q.execute(name);
39 41
40 if (devTeam == null) {42 if (results.isEmpty()) {
41 throw new DevTeamNotExists(name);43 throw new DevTeamNotExists(name);
42 }44 }
43 45
44 return devTeam;46 return results.get(0);
45 }47 }
46 /**48 /**
47 * Gets the DevTeamDataData by its primary key - READ ONLY49 * Gets the DevTeamDataData by its primary key - READ ONLY
4850
=== modified file 'src/au/edu/unimelb/csse/mugle/server/model/GameFileData.java'
--- src/au/edu/unimelb/csse/mugle/server/model/GameFileData.java 2011-04-29 07:02:27 +0000
+++ src/au/edu/unimelb/csse/mugle/server/model/GameFileData.java 2011-04-29 07:02:27 +0000
@@ -17,9 +17,6 @@
1717
18package au.edu.unimelb.csse.mugle.server.model;18package au.edu.unimelb.csse.mugle.server.model;
1919
20import java.util.HashSet;
21import java.util.Set;
22
23import javax.jdo.annotations.IdGeneratorStrategy;20import javax.jdo.annotations.IdGeneratorStrategy;
24import javax.jdo.annotations.PersistenceCapable;21import javax.jdo.annotations.PersistenceCapable;
25import javax.jdo.annotations.Persistent;22import javax.jdo.annotations.Persistent;
@@ -54,17 +51,16 @@
5451
55 @UserLevel(privateView=Role.DEVELOPER, publicView=Role.DEVELOPER, useMethod=true, mappedBy="getBlobKeyString")52 @UserLevel(privateView=Role.DEVELOPER, publicView=Role.DEVELOPER, useMethod=true, mappedBy="getBlobKeyString")
56 @Persistent53 @Persistent
57 private BlobKey blobKey; //key to the actual blob54 private BlobKey blobKey; //key to the actual blob -- may be shared between GameFiles across versions
58 55
59 // Many-to-many56 @UserLevel(privateView=Role.DEVELOPER, publicView=Role.DEVELOPER, mappedBy="version")
60 @UserLevel(privateView=Role.DEVELOPER, publicView=Role.DEVELOPER, useMethod=true, mappedBy="keysToGameVersions")
61 @Persistent57 @Persistent
62 private Set<Key> versions; //Game versions this file belongs to58 private GameVersionData version; //Game version this Gamefile belongs to
6359
6460
65 // Constructors61 // Constructors
66 public GameFileData() {62 public GameFileData() {
67 this.versions = new HashSet<Key>();63 this.version = null;
68 this.setMimeType(null);64 this.setMimeType(null);
69 this.setBlobKey(null);65 this.setBlobKey(null);
70 this.path = null;66 this.path = null;
@@ -101,8 +97,8 @@
101 return this.path;97 return this.path;
102 }98 }
10399
104 public Set<Key> getGameVersions() {100 public GameVersionData getGameVersions() {
105 return this.versions;101 return this.version;
106 }102 }
107103
108104
@@ -139,23 +135,6 @@
139 }135 }
140*/136*/
141137
142 public boolean addGameVersion(GameVersionData version) {
143 // many-to-many relationship
144 if (this.versions.add(version.getServerKey()))
145 {
146 return version.getGameFiles().add(this.getServerKey());
147 }
148 return false;
149 }
150
151 public boolean removeGameVersion(GameVersionData version) {
152 // many-to-many relationship
153 if (this.versions.remove(version.getServerKey()))
154 {
155 return version.getGameFiles().remove(this.getServerKey());
156 }
157 return false;
158 }
159 138
160/** TODO: Pending Blob implementation for files139/** TODO: Pending Blob implementation for files
161 public GameFileData(String path, GameVersion version, InputStream contents) {140 public GameFileData(String path, GameVersion version, InputStream contents) {
@@ -183,10 +162,6 @@
183 public Class<GameFile> getClientClassType() {162 public Class<GameFile> getClientClassType() {
184 return GameFile.class;163 return GameFile.class;
185 }164 }
186
187 public Set<Long> keysToGameVersions() {
188 return this.fetchClientObjects(GameVersionData.class, this.versions);
189 }
190165
191 public String getBlobKeyString() {166 public String getBlobKeyString() {
192 return this.blobKey.getKeyString();167 return this.blobKey.getKeyString();
193168
=== added file 'src/au/edu/unimelb/csse/mugle/server/model/GameFileGetter.java'
--- src/au/edu/unimelb/csse/mugle/server/model/GameFileGetter.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/server/model/GameFileGetter.java 2011-04-29 07:02:27 +0000
@@ -0,0 +1,116 @@
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 java.util.List;
21
22import javax.jdo.PersistenceManager;
23import javax.jdo.Query;
24
25import au.edu.unimelb.csse.mugle.server.PMF;
26import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameFileNotExists;
27import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameNotExists;
28import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameVersionNotExists;
29
30public class GameFileGetter {
31 /**
32 * Gets the GameFile by its Primary Key - READ ONLY
33 * @param primaryKey
34 * @return the GameFile - read only
35 * @throws GameFileNotExists
36 */
37 public GameFileData getGameFile(Long primaryKey) throws GameFileNotExists {
38 PersistenceManager pm = PMF.getManager();
39 try {
40 return getGameFile(pm, primaryKey);
41 } finally {
42 pm.close();
43 }
44 }
45
46 /**
47 * Gets the GameFile by its Primary Key, for editing object in datastore
48 * PersistenceManager must be handled by the caller
49 * @param pm the PersistenceManager
50 * @param primaryKey
51 * @return the GameFile
52 * @throws GameFileNotExists
53 */
54 public GameFileData getGameFile(PersistenceManager pm, Long primaryKey) throws GameFileNotExists{
55 GameFileData gameFile = pm.getObjectById(GameFileData.class, primaryKey);
56
57 if(gameFile == null) {
58 throw new GameFileNotExists(primaryKey);
59 }
60
61 return gameFile;
62 }
63
64 /**
65 * Gets the GameFile by its path, version and game - READ ONLY
66 * @param gameName the name of the game
67 * @param gameVersion the version of the game
68 * @param path the path of the file
69 * @return the GameFile - read only
70 * @throws GameNotExists
71 * @throws GameVersionNotExists
72 * @throws GameFileNotExists
73 */
74 public GameFileData getGameFile(String gameName, String gameVersion, String path)
75 throws GameNotExists, GameVersionNotExists, GameFileNotExists {
76 PersistenceManager pm = PMF.getManager();
77 try {
78 return getGameFile(pm, gameName, gameVersion, path);
79 } finally {
80 pm.close();
81 }
82 }
83
84 /**
85 * Gets the GameFile by its path, version and game, for editing object in datastore
86 * PersistenceManager must be handled by the caller
87 * @para pm The Persistence Manager
88 * @param gameName the name of the game
89 * @param gameVersion the version of the game
90 * @param path the path of the file
91 * @return the GameFile - read only
92 * @throws GameNotExists
93 * @throws GameVersionNotExists
94 * @throws GameFileNotExists
95 */
96
97
98 @SuppressWarnings("unchecked")
99 public GameFileData getGameFile(PersistenceManager pm, String gameName, String gameVersion, String path)
100 throws GameFileNotExists, GameNotExists, GameVersionNotExists {
101 GameVersionGetter gvg = new GameVersionGetter();
102 GameVersionData gv = gvg.getGameVersion(pm, gameName, gameVersion);
103
104
105 Query q = pm.newQuery(GameFileData.class, "path == p && version == v");
106 q.declareParameters("String p, GameVersionData v");
107 List<GameFileData> results = (List<GameFileData>) q.execute(path, gv);
108
109 if (results.isEmpty()) {
110 throw new GameFileNotExists(gameName, gameVersion, path);
111 }
112
113 return results.get(0);
114 }
115
116}
0117
=== modified file 'src/au/edu/unimelb/csse/mugle/server/model/GameVersionData.java'
--- src/au/edu/unimelb/csse/mugle/server/model/GameVersionData.java 2011-04-08 11:00:59 +0000
+++ src/au/edu/unimelb/csse/mugle/server/model/GameVersionData.java 2011-04-29 07:02:27 +0000
@@ -73,16 +73,15 @@
73 @Element(dependent="true")73 @Element(dependent="true")
74 private PromotedGameData promotedGame;74 private PromotedGameData promotedGame;
7575
76 // Many-to-many
77 @UserLevel(privateView=Role.DEVELOPER, publicView=Role.DEVELOPER, useMethod=true, mappedBy="keysToGameFiles")76 @UserLevel(privateView=Role.DEVELOPER, publicView=Role.DEVELOPER, useMethod=true, mappedBy="keysToGameFiles")
78 @Persistent77 @Persistent(mappedBy="version")
79 private Set<Key> gameFiles;78 private Set<GameFileData> gameFiles;
8079
81 // Constructors80 // Constructors
82 81
83 public GameVersionData() {82 public GameVersionData() {
8483
85 this.gameFiles = new HashSet<Key>();84 this.gameFiles = new HashSet<GameFileData>();
86 this.promotedGame = null;85 this.promotedGame = null;
87 this.game = null;86 this.game = null;
88 //this.version = null;87 //this.version = null;
@@ -98,7 +97,7 @@
98 */97 */
99 public GameVersionData(GameData game, String displayVersion, String fullName, String description) {98 public GameVersionData(GameData game, String displayVersion, String fullName, String description) {
10099
101 this.gameFiles = new HashSet<Key>();100 this.gameFiles = new HashSet<GameFileData>();
102 this.promotedGame = null;101 this.promotedGame = null;
103 102
104 /* To be unique, the Primary key must be made up of the ID of the UGP and 103 /* To be unique, the Primary key must be made up of the ID of the UGP and
@@ -142,7 +141,7 @@
142 * }141 * }
143 */142 */
144 143
145 public Set<Key> getGameFiles() {144 public Set<GameFileData> getGameFiles() {
146 return this.gameFiles;145 return this.gameFiles;
147 }146 }
148147
@@ -175,31 +174,6 @@
175174
176 // TODO: setImage(Image image);175 // TODO: setImage(Image image);
177176
178
179 // Misc methods
180
181 public boolean addGameFile(GameFileData file) {
182 // many-to-many relationship
183 if (this.gameFiles.add(file.getServerKey())) {
184 return file.getGameVersions().add(this.getServerKey());
185 }
186 return false;
187 }
188
189 public boolean removeGameFile(GameFileData file) {
190 // many-to-many relationship
191 if (this.gameFiles.remove(file.getServerKey())) {
192 if (file.getGameVersions().remove(this.getServerKey()))
193 {
194 // delete file if this is the only reference
195 if (file.getGameVersions().isEmpty()) {
196 // TODO: delete the file off the database
197 // is this automatically done by GAE?
198 }
199 }
200 }
201 return false;
202 }
203 177
204 @Override178 @Override
205 public Key getServerKey() {179 public Key getServerKey() {
@@ -225,9 +199,9 @@
225 public Class<GameVersion> getClientClassType() {199 public Class<GameVersion> getClientClassType() {
226 return GameVersion.class;200 return GameVersion.class;
227 }201 }
228 202
229 public Set<String> keysToGameFiles() {203 public Set<String> keysToGameFiles() {
230 return this.fetchClientObjects(GameFileData.class, this.gameFiles);204 return this.fetchClientObjects(this.gameFiles);
231 }205 }
232206
233}207}
234208
=== added file 'src/au/edu/unimelb/csse/mugle/server/model/GameVersionGetter.java'
--- src/au/edu/unimelb/csse/mugle/server/model/GameVersionGetter.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/server/model/GameVersionGetter.java 2011-04-29 07:02:27 +0000
@@ -0,0 +1,107 @@
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 java.util.List;
21
22import javax.jdo.PersistenceManager;
23import javax.jdo.Query;
24
25import au.edu.unimelb.csse.mugle.server.PMF;
26import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameNotExists;
27import au.edu.unimelb.csse.mugle.shared.platform.exceptions.GameVersionNotExists;
28
29public class GameVersionGetter {
30 /**
31 * Gets the GameVersion by its Primary Key - READ ONLY
32 * @param primaryKey
33 * @return the GameVersion - read only
34 * @throws GameVersionNotExists
35 */
36 public GameVersionData getGameVersion(Long primaryKey) throws GameVersionNotExists {
37 PersistenceManager pm = PMF.getManager();
38 try {
39 return getGameVersion(pm, primaryKey);
40 } finally {
41 pm.close();
42 }
43 }
44
45 /**
46 * Gets the GameVersion by its Primary Key, for editing object in datstore
47 * PersistenceManager must be handled by the caller
48 * @param pm the PersistenceManager
49 * @param primaryKey
50 * @return the GameVersion
51 * @throws GameVersionNotExists
52 */
53 public GameVersionData getGameVersion(PersistenceManager pm, Long primaryKey) throws GameVersionNotExists{
54 GameVersionData gameversion = pm.getObjectById(GameVersionData.class, primaryKey);
55
56 if(gameversion == null) {
57 throw new GameVersionNotExists(primaryKey);
58 }
59
60 return gameversion;
61 }
62
63 /**
64 * Gets the GameVersion by its display Version - READ ONLY
65 * @param gameName the name of the Game that it belongs to
66 * @param dispVersion the displayed version number
67 * @return the GameVersion - read only
68 * @throws GameVersionNotExists
69 */
70 public GameVersionData getGameVersion(String gameName, String dispVersion)
71 throws GameVersionNotExists, GameNotExists {
72 PersistenceManager pm = PMF.getManager();
73 try {
74 return getGameVersion(pm, gameName, dispVersion);
75 } finally {
76 pm.close();
77 }
78 }
79
80 /**
81 * Gets the GameVersion by its display name, for editing object in datastore
82 * PersistenceManager must be handled by the caller
83 * @param pm the PersistenceManager
84 * @param gameName the name of the Game that it belongs to
85 * @param dispVersion the displayed version number
86 * @return the GameVersion
87 * @throws GameVersionNotExists
88 * @throws GameNotExists
89 */
90 @SuppressWarnings("unchecked")
91 public GameVersionData getGameVersion(PersistenceManager pm, String gameName, String dispVersion)
92 throws GameVersionNotExists, GameNotExists{
93 GameGetter g = new GameGetter();
94 GameData game = g.getGame(pm, gameName);
95
96 Query q = pm.newQuery(GameData.class, "dispVersion == d && game == g");
97 q.declareParameters("String d, GameData g");
98 List<GameVersionData> results = (List<GameVersionData>) q.execute(dispVersion, game);
99
100 if(results.isEmpty()) {
101 throw new GameNotExists(dispVersion, game.getUrlName());
102 }
103
104 return results.get(0);
105 }
106}
107
0108
=== modified file 'src/au/edu/unimelb/csse/mugle/server/model/KeyValuePairGetter.java'
--- src/au/edu/unimelb/csse/mugle/server/model/KeyValuePairGetter.java 2011-04-29 07:02:27 +0000
+++ src/au/edu/unimelb/csse/mugle/server/model/KeyValuePairGetter.java 2011-04-29 07:02:27 +0000
@@ -16,6 +16,8 @@
16 */16 */
17package au.edu.unimelb.csse.mugle.server.model;17package au.edu.unimelb.csse.mugle.server.model;
1818
19import java.util.List;
20
19import javax.jdo.PersistenceManager;21import javax.jdo.PersistenceManager;
20import javax.jdo.Query;22import javax.jdo.Query;
2123
@@ -37,7 +39,7 @@
37 * @throws KeyError39 * @throws KeyError
38 */40 */
39 public KeyValuePairData getKeyValuePair(String key, String gameToken) 41 public KeyValuePairData getKeyValuePair(String key, String gameToken)
40 throws UserNotExists, GameTokenError, KeyError {42 throws GameTokenError, KeyError {
41 PersistenceManager pm = PMF.getManager();43 PersistenceManager pm = PMF.getManager();
42 try {44 try {
43 return getKeyValuePair(pm, key, gameToken);45 return getKeyValuePair(pm, key, gameToken);
@@ -60,7 +62,7 @@
60 * @throws KeyError62 * @throws KeyError
61 */63 */
62 public KeyValuePairData getKeyValuePair(PersistenceManager pm, String key, String gameToken) 64 public KeyValuePairData getKeyValuePair(PersistenceManager pm, String key, String gameToken)
63 throws UserNotExists, GameTokenError, KeyError {65 throws GameTokenError, KeyError {
64 return getKeyValuePair(pm, key, gameToken, false);66 return getKeyValuePair(pm, key, gameToken, false);
65 }67 }
6668
@@ -79,30 +81,32 @@
79 * @throws GameTokenError81 * @throws GameTokenError
80 * @throws KeyError82 * @throws KeyError
81 */83 */
84 @SuppressWarnings("unchecked")
82 public KeyValuePairData getKeyValuePair(PersistenceManager pm, String key, String gameToken, boolean createIfNotFound) 85 public KeyValuePairData getKeyValuePair(PersistenceManager pm, String key, String gameToken, boolean createIfNotFound)
83 throws UserNotExists, GameTokenError, KeyError {86 throws GameTokenError, KeyError {
84 UserGameProfileGetter u = new UserGameProfileGetter();87 UserGameProfileGetter u = new UserGameProfileGetter();
85 UserGameProfileData ugp = u.getCurrentUserGameProfile(pm, gameToken);88 UserGameProfileData ugp = u.getCurrentUserGameProfile(pm, gameToken);
86 89
87 KeyValuePairData kvp = null;
88
89 Query q = pm.newQuery(KeyValuePairData.class, "key == k && ugp == u");90 Query q = pm.newQuery(KeyValuePairData.class, "key == k && ugp == u");
90 q.declareParameters("String k, UserGameProfileData u");91 q.declareParameters("String k, UserGameProfileData u");
91 kvp = (KeyValuePairData) q.execute(key, ugp);92 List<KeyValuePairData> results = (List<KeyValuePairData>) q.execute(key, ugp);
92 93
93 /* If the key value pair isn't found - we want to create one if 94 /* If the key value pair isn't found - we want to create one if
94 * createIfNotFound is set to true95 * createIfNotFound is set to true
95 */96 */
96 if (kvp == null) {97 if (results.isEmpty()) {
97 if (createIfNotFound) {98 if (createIfNotFound) {
98 kvp = new KeyValuePairData();99 KeyValuePairData kvp = new KeyValuePairData();
99 kvp.setKey(key);100 kvp.setKey(key);
100 kvp.setUserGameProfile(ugp);101 kvp.setUserGameProfile(ugp);
102 pm.makePersistent(kvp);
103
104 results.add(kvp);
101 } else {105 } else {
102 throw new KeyError(key);106 throw new KeyError(key);
103 }107 }
104 }108 }
105 109
106 return kvp;110 return results.get(0);
107 }111 }
108}112}
109113
=== modified file 'src/au/edu/unimelb/csse/mugle/server/model/ModelDataClass.java'
--- src/au/edu/unimelb/csse/mugle/server/model/ModelDataClass.java 2011-04-29 07:02:27 +0000
+++ src/au/edu/unimelb/csse/mugle/server/model/ModelDataClass.java 2011-04-29 07:02:27 +0000
@@ -98,5 +98,17 @@
98 return list;98 return list;
99 99
100 }100 }
101
102 protected <A, C extends ModelDataClass<A,?,C>> Set<A> fetchClientObjects(Set<C> dataList) {
103
104 HashSet<A> list = new HashSet<A>(dataList.size());
105
106 for (C cls : dataList) {
107 list.add(cls.getPrimaryKey());
108 }
109
110 return list;
111
112 }
101 113
102}114}
103115
=== modified file 'src/au/edu/unimelb/csse/mugle/server/model/ModelWrapper.java'
--- src/au/edu/unimelb/csse/mugle/server/model/ModelWrapper.java 2011-04-29 07:02:27 +0000
+++ src/au/edu/unimelb/csse/mugle/server/model/ModelWrapper.java 2011-04-29 07:02:27 +0000
@@ -20,11 +20,17 @@
20import java.lang.reflect.*;20import java.lang.reflect.*;
2121
22import javax.jdo.PersistenceManager;22import javax.jdo.PersistenceManager;
23import javax.jdo.Query;
24
25import com.google.appengine.api.users.User;
26import com.google.appengine.api.users.UserService;
27import com.google.appengine.api.users.UserServiceFactory;
2328
24import au.edu.unimelb.csse.mugle.server.model.annotations.*;29import au.edu.unimelb.csse.mugle.server.model.annotations.*;
25import au.edu.unimelb.csse.mugle.server.PMF;30import au.edu.unimelb.csse.mugle.server.PMF;
26import au.edu.unimelb.csse.mugle.shared.model.*;31import au.edu.unimelb.csse.mugle.shared.model.*;
27import au.edu.unimelb.csse.mugle.shared.model.annotations.*;32import au.edu.unimelb.csse.mugle.shared.model.annotations.*;
33import au.edu.unimelb.csse.mugle.shared.platform.exceptions.ServerException;
28import au.edu.unimelb.csse.mugle.shared.platform.exceptions.UserPrivilegeException;34import au.edu.unimelb.csse.mugle.shared.platform.exceptions.UserPrivilegeException;
2935
30public final class ModelWrapper {36public final class ModelWrapper {
@@ -58,7 +64,7 @@
58 case DEVELOPER:64 case DEVELOPER:
59 return (role == Role.ADMIN || role == Role.DEVELOPER);65 return (role == Role.ADMIN || role == Role.DEVELOPER);
60 66
61 case USER:67 case GUEST:
62 return true;68 return true;
63 69
64 default:70 default:
@@ -168,8 +174,8 @@
168 * @throws IllegalArgumentException 174 * @throws IllegalArgumentException
169 * @throws NoSuchMethodException 175 * @throws NoSuchMethodException
170 */176 */
171 public static <T extends ModelClass<?,T>, U extends ModelDataClass<?,T,U>, B extends ModelClass<?,B>, C extends ModelDataClass<?,B,C>>177 public static <T extends ModelClass<?,T>, U extends ModelDataClass<?,T,U>>
172 T getClientClone(U obj, Role role, ClientView cview)178 T getClientClone(U obj, Role role, ClientView cview)
173 throws InstantiationException, IllegalAccessException, SecurityException,179 throws InstantiationException, IllegalAccessException, SecurityException,
174 NoSuchFieldException, NoSuchMethodException, IllegalArgumentException,180 NoSuchFieldException, NoSuchMethodException, IllegalArgumentException,
175 InvocationTargetException {181 InvocationTargetException {
@@ -230,6 +236,37 @@
230 return stripped;236 return stripped;
231 237
232 }238 }
239
240 public static <T extends ModelClass<?,T>, U extends ModelDataClass<?,T,U>>
241 T getClientCloneSafe(U obj, Role role, ClientView cview)
242 throws ServerException {
243
244 try {
245 return getClientClone(obj, role, cview);
246 } catch (SecurityException e) {
247 e.printStackTrace();
248 throw new ServerException(e.getMessage());
249 } catch (IllegalArgumentException e) {
250 e.printStackTrace();
251 throw new ServerException(e.getMessage());
252 } catch (InstantiationException e) {
253 e.printStackTrace();
254 throw new ServerException(e.getMessage());
255 } catch (IllegalAccessException e) {
256 e.printStackTrace();
257 throw new ServerException(e.getMessage());
258 } catch (NoSuchFieldException e) {
259 e.printStackTrace();
260 throw new ServerException(e.getMessage());
261 } catch (NoSuchMethodException e) {
262 e.printStackTrace();
263 throw new ServerException(e.getMessage());
264 } catch (InvocationTargetException e) {
265 e.printStackTrace();
266 throw new ServerException(e.getMessage());
267 }
268
269 }
233 270
234 /**271 /**
235 * Converts a ModelClass instance to its counter part ModelDataClass,272 * Converts a ModelClass instance to its counter part ModelDataClass,
@@ -655,10 +692,22 @@
655692
656693
657 // Current login privileges694 // Current login privileges
658 695
659 public static Role getCurrentRole() {696 public static Role getCurrentRole() {
660 // TODO needs to actually check login details and return the actual role.697
661 return Role.USER;698 UserService userService = UserServiceFactory.getUserService();
699 User user = userService.getCurrentUser();
700
701 PersistenceManager pm = PMF.getManager();
702 if (pm == null) { return Role.NONE; }
703
704 Query q = pm.newQuery(UserData.class, "googleID == i || email == e");
705 q.declareParameters("String i, String e");
706 UserData ud = (UserData) q.execute(user.getUserId(), user.getEmail());
707 if (ud == null) { return Role.NONE; }
708
709 return ud.getRole();
710
662 }711 }
663 712
664 public static ClientView getCurrentClientView() {713 public static ClientView getCurrentClientView() {
665714
=== modified file 'src/au/edu/unimelb/csse/mugle/server/model/UserAchievementGetter.java'
--- src/au/edu/unimelb/csse/mugle/server/model/UserAchievementGetter.java 2011-04-29 07:02:27 +0000
+++ src/au/edu/unimelb/csse/mugle/server/model/UserAchievementGetter.java 2011-04-29 07:02:27 +0000
@@ -17,6 +17,8 @@
1717
18package au.edu.unimelb.csse.mugle.server.model;18package au.edu.unimelb.csse.mugle.server.model;
1919
20import java.util.List;
21
20import javax.jdo.PersistenceManager;22import javax.jdo.PersistenceManager;
21import javax.jdo.Query;23import javax.jdo.Query;
2224
@@ -37,7 +39,7 @@
37 * @throws AchievementNotExists39 * @throws AchievementNotExists
38 */40 */
39 public UserAchievementData getUserAchievement(String achievementName, String gameToken) 41 public UserAchievementData getUserAchievement(String achievementName, String gameToken)
40 throws UserNotExists, GameTokenError, AchievementNotExists {42 throws GameTokenError, AchievementNotExists {
41 PersistenceManager pm = PMF.getManager();43 PersistenceManager pm = PMF.getManager();
42 try {44 try {
43 return getUserAchievement(pm, achievementName, gameToken);45 return getUserAchievement(pm, achievementName, gameToken);
@@ -58,8 +60,9 @@
58 * @throws GameTokenError60 * @throws GameTokenError
59 * @throws AchievementNotExists61 * @throws AchievementNotExists
60 */62 */
63 @SuppressWarnings("unchecked")
61 public UserAchievementData getUserAchievement(PersistenceManager pm, String achievementName, String gameToken) 64 public UserAchievementData getUserAchievement(PersistenceManager pm, String achievementName, String gameToken)
62 throws UserNotExists, GameTokenError, AchievementNotExists {65 throws GameTokenError, AchievementNotExists {
63 UserGameProfileGetter u = new UserGameProfileGetter();66 UserGameProfileGetter u = new UserGameProfileGetter();
64 AchievementGetter a = new AchievementGetter();67 AchievementGetter a = new AchievementGetter();
65 68
@@ -68,17 +71,20 @@
68 71
69 Query q = pm.newQuery(UserAchievementData.class, "ugp == u && achievement == a");72 Query q = pm.newQuery(UserAchievementData.class, "ugp == u && achievement == a");
70 q.declareParameters("UserGameProfileData ugp, AchievementData a");73 q.declareParameters("UserGameProfileData ugp, AchievementData a");
71 UserAchievementData ua = (UserAchievementData) q.execute(ugp, achievement);74 List<UserAchievementData> results = (List<UserAchievementData>) q.execute(ugp, achievement);
72 75
73 /* If we can't find the UserAchievement it makes sense to create one76 /* If we can't find the UserAchievement it makes sense to create one
74 * if the UserGameProfile and the Achievement exist.77 * if the UserGameProfile and the Achievement exist.
75 */78 */
76 if (ua == null) {79 if (results.isEmpty()) {
77 ua = new UserAchievementData();80 UserAchievementData ua = new UserAchievementData();
78 ua.setAchievement(achievement);81 ua.setAchievement(achievement);
79 ua.setUserGameProfile(ugp);82 ua.setUserGameProfile(ugp);
83 pm.makePersistent(ua);
84
85 results.add(ua);
80 }86 }
81 87
82 return ua;88 return results.get(0);
83 }89 }
84}90}
8591
=== modified file 'src/au/edu/unimelb/csse/mugle/server/model/UserGameProfileGetter.java'
--- src/au/edu/unimelb/csse/mugle/server/model/UserGameProfileGetter.java 2011-04-29 07:02:27 +0000
+++ src/au/edu/unimelb/csse/mugle/server/model/UserGameProfileGetter.java 2011-04-29 07:02:27 +0000
@@ -17,6 +17,8 @@
1717
18package au.edu.unimelb.csse.mugle.server.model;18package au.edu.unimelb.csse.mugle.server.model;
1919
20import java.util.List;
21
20import javax.jdo.PersistenceManager;22import javax.jdo.PersistenceManager;
21import javax.jdo.Query;23import javax.jdo.Query;
2224
@@ -68,7 +70,7 @@
68 * @throws GameTokenError70 * @throws GameTokenError
69 */71 */
70 public UserGameProfileData getCurrentUserGameProfile(String gameToken) 72 public UserGameProfileData getCurrentUserGameProfile(String gameToken)
71 throws UserNotExists, GameTokenError {73 throws GameTokenError {
72 PersistenceManager pm = PMF.getManager();74 PersistenceManager pm = PMF.getManager();
73 try {75 try {
74 return getCurrentUserGameProfile(pm, gameToken);76 return getCurrentUserGameProfile(pm, gameToken);
@@ -87,27 +89,31 @@
87 * @throws UserNotExists89 * @throws UserNotExists
88 * @throws GameTokenError90 * @throws GameTokenError
89 */91 */
92 @SuppressWarnings("unchecked")
90 public UserGameProfileData getCurrentUserGameProfile(PersistenceManager pm, String gameToken) 93 public UserGameProfileData getCurrentUserGameProfile(PersistenceManager pm, String gameToken)
91 throws UserNotExists, GameTokenError {94 throws GameTokenError {
92 UserGetter u = new UserGetter();95 UserGetter u = new UserGetter();
93 GameGetter g = new GameGetter();96 GameGetter g = new GameGetter();
94 UserData curUser = u.getCurrentUser(pm);97 UserData curUser = u.getCurrentUser(pm);
95 GameData curGame = g.getCurrentGame(pm, gameToken);98 GameData curGame = g.getCurrentGame(pm, gameToken);
96 UserGameProfileData ugp = null;99
97 100
98 Query q = pm.newQuery(UserGameProfileData.class, "user == u && game == g");101 Query q = pm.newQuery(UserGameProfileData.class, "user == u && game == g");
99 q.declareParameters("UserData u, GameData g");102 q.declareParameters("UserData u, GameData g");
100 ugp = (UserGameProfileData) q.execute(curUser, curGame);103 List<UserGameProfileData> results = (List<UserGameProfileData>) q.execute(curUser, curGame);
101 104
102 /* If we can't find the UserGameProfile it makes sense to create one105 /* If we can't find the UserGameProfile it makes sense to create one
103 * if the user is playing the game106 * if the user is playing the game
104 */107 */
105 if (ugp == null) {108 if (results.isEmpty()) {
106 ugp = new UserGameProfileData();109 UserGameProfileData ugp = new UserGameProfileData();
107 ugp.setGame(curGame);110 ugp.setGame(curGame);
108 ugp.setUser(curUser);111 ugp.setUser(curUser);
112 pm.makePersistent(ugp);
113
114 results.add(ugp);
109 }115 }
110 return ugp;116 return results.get(0);
111 }117 }
112118
113}119}
114120
=== modified file 'src/au/edu/unimelb/csse/mugle/server/model/UserGetter.java'
--- src/au/edu/unimelb/csse/mugle/server/model/UserGetter.java 2011-04-29 07:02:27 +0000
+++ src/au/edu/unimelb/csse/mugle/server/model/UserGetter.java 2011-04-29 07:02:27 +0000
@@ -20,9 +20,12 @@
20import javax.jdo.PersistenceManager;20import javax.jdo.PersistenceManager;
21import javax.jdo.Query;21import javax.jdo.Query;
2222
23import java.util.List;
24
23import au.edu.unimelb.csse.mugle.client.LoginInfo;25import au.edu.unimelb.csse.mugle.client.LoginInfo;
24import au.edu.unimelb.csse.mugle.server.LoginServiceImpl;26import au.edu.unimelb.csse.mugle.server.ClientServiceImpl;
25import au.edu.unimelb.csse.mugle.server.PMF;27import au.edu.unimelb.csse.mugle.server.PMF;
28import au.edu.unimelb.csse.mugle.shared.model.Role;
26import au.edu.unimelb.csse.mugle.shared.platform.exceptions.UserNotExists;29import au.edu.unimelb.csse.mugle.shared.platform.exceptions.UserNotExists;
2730
28public class UserGetter {31public class UserGetter {
@@ -82,16 +85,17 @@
82 * @return The User class85 * @return The User class
83 * @throws UserNotExists86 * @throws UserNotExists
84 */87 */
88 @SuppressWarnings("unchecked")
85 public UserData getUserByName(PersistenceManager pm, String name) throws UserNotExists {89 public UserData getUserByName(PersistenceManager pm, String name) throws UserNotExists {
86 Query q = pm.newQuery(UserData.class, "urlName == u");90 Query q = pm.newQuery(UserData.class, "urlName == u");
87 q.declareParameters("String u");91 q.declareParameters("String u");
88 UserData u = (UserData) q.execute(name);92 List<UserData> results = (List<UserData>) q.execute(name);
89 93
90 if (u == null) {94 if (results.isEmpty()) {
91 throw new UserNotExists(name);95 throw new UserNotExists(name);
92 }96 }
93 97
94 return u;98 return results.get(0);
95 }99 }
96 100
97 /**101 /**
@@ -117,24 +121,24 @@
117 * @return The User class121 * @return The User class
118 * @throws UserNotExists122 * @throws UserNotExists
119 */123 */
124 @SuppressWarnings("unchecked")
120 public UserData getUser(PersistenceManager pm, String googleID) throws UserNotExists {125 public UserData getUser(PersistenceManager pm, String googleID) throws UserNotExists {
121 Query q = pm.newQuery(UserData.class, "googleID == u");126 Query q = pm.newQuery(UserData.class, "googleID == u");
122 q.declareParameters("String u");127 q.declareParameters("String u");
123 UserData u = (UserData) q.execute(googleID);128 List<UserData> results = (List<UserData>) q.execute(googleID);
124 129
125 if (u == null) {130 if (results.isEmpty()) {
126 throw new UserNotExists(googleID);131 throw new UserNotExists(googleID);
127 }132 }
128 133
129 return u;134 return results.get(0);
130 }135 }
131 136
132 /**137 /**
133 * Gets the currently logged in User - READ ONLY138 * Gets the currently logged in User - READ ONLY
134 * @return the User - read only139 * @return the User - read only
135 * @throws UserNotExists
136 */140 */
137 public UserData getCurrentUser() throws UserNotExists {141 public UserData getCurrentUser() {
138 PersistenceManager pm = PMF.getManager();142 PersistenceManager pm = PMF.getManager();
139 try {143 try {
140 return getCurrentUser(pm);144 return getCurrentUser(pm);
@@ -144,17 +148,35 @@
144 }148 }
145 149
146 /**150 /**
147 * Gets the currently logged in User, for editing object in datstore151 * Gets the currently logged in User, for editing object in datastore
152 * Creates a new user if the currently logged in user is not found
148 * Persistence Manager must be handled by the caller153 * Persistence Manager must be handled by the caller
149 * @param pm The Persistence Manager154 * @param pm The Persistence Manager
150 * @return the current User155 * @return the current User
151 * @throws UserNotExists
152 */156 */
153 public UserData getCurrentUser(PersistenceManager pm) throws UserNotExists {157 public UserData getCurrentUser(PersistenceManager pm) {
154 LoginServiceImpl loginService = new LoginServiceImpl();158 ClientServiceImpl loginService = new ClientServiceImpl();
155 LoginInfo loginInfo = loginService.getCurrentUser();159 LoginInfo loginInfo = loginService.getCurrentUser();
156 160
157 return getUser(pm, loginInfo.getUserID());161 try {
162 return getUser(pm, loginInfo.getUserID());
163 } catch (UserNotExists e) {
164 UserData newUser = new UserData();
165
166 //Creates the new user using the info provided by google
167 newUser.setGoogleID(loginInfo.getUserID());
168 newUser.setUrlName(loginInfo.getNickname());
169 newUser.setFullName(loginInfo.getNickname());
170 newUser.setEmail(loginInfo.getEmailAddress());
171 newUser.setRole(Role.DEVELOPER);
172 newUser.setActive(true);
173
174 //Stores the new user in the datastore
175 pm.makePersistent(newUser);
176
177 return newUser;
178 }
179
158 }180 }
159181
160}182}
161183
=== modified file 'src/au/edu/unimelb/csse/mugle/server/model/annotations/UserLevel.java'
--- src/au/edu/unimelb/csse/mugle/server/model/annotations/UserLevel.java 2011-03-31 09:56:28 +0000
+++ src/au/edu/unimelb/csse/mugle/server/model/annotations/UserLevel.java 2011-04-29 07:02:27 +0000
@@ -27,8 +27,8 @@
27@Target(ElementType.FIELD)27@Target(ElementType.FIELD)
28@Retention(RetentionPolicy.RUNTIME)28@Retention(RetentionPolicy.RUNTIME)
29public @interface UserLevel {29public @interface UserLevel {
30 Role privateView() default Role.USER;30 Role privateView() default Role.GUEST;
31 Role publicView() default Role.USER;31 Role publicView() default Role.GUEST;
32 boolean useMethod() default false;32 boolean useMethod() default false;
33 boolean mapField() default true;33 boolean mapField() default true;
34 String mappedBy() default "";34 String mappedBy() default "";
3535
=== modified file 'src/au/edu/unimelb/csse/mugle/server/platform/DeveloperServiceImpl.java'
--- src/au/edu/unimelb/csse/mugle/server/platform/DeveloperServiceImpl.java 2011-04-29 07:02:27 +0000
+++ src/au/edu/unimelb/csse/mugle/server/platform/DeveloperServiceImpl.java 2011-04-29 07:02:27 +0000
@@ -23,7 +23,7 @@
23import au.edu.unimelb.csse.mugle.shared.platform.exceptions.*;23import au.edu.unimelb.csse.mugle.shared.platform.exceptions.*;
2424
25@SuppressWarnings("serial")25@SuppressWarnings("serial")
26public class DeveloperServiceImpl extends UserServiceImpl implements DeveloperService {26public class DeveloperServiceImpl extends GuestServiceImpl implements DeveloperService {
2727
28 @Override28 @Override
29 public GameVersion addGameVersion(GameVersion gameVersion)29 public GameVersion addGameVersion(GameVersion gameVersion)
3030
=== renamed file 'src/au/edu/unimelb/csse/mugle/server/platform/UserServiceImpl.java' => 'src/au/edu/unimelb/csse/mugle/server/platform/GuestServiceImpl.java'
--- src/au/edu/unimelb/csse/mugle/server/platform/UserServiceImpl.java 2011-03-26 14:01:07 +0000
+++ src/au/edu/unimelb/csse/mugle/server/platform/GuestServiceImpl.java 2011-04-29 07:02:27 +0000
@@ -19,9 +19,21 @@
1919
20import com.google.gwt.user.server.rpc.RemoteServiceServlet;20import com.google.gwt.user.server.rpc.RemoteServiceServlet;
2121
22import au.edu.unimelb.csse.mugle.client.platform.UserService;22import au.edu.unimelb.csse.mugle.client.platform.GuestService;
23import au.edu.unimelb.csse.mugle.server.model.*;
24import au.edu.unimelb.csse.mugle.shared.model.*;
25import au.edu.unimelb.csse.mugle.shared.platform.exceptions.ServerException;
2326
24@SuppressWarnings("serial")27@SuppressWarnings("serial")
25public class UserServiceImpl extends RemoteServiceServlet implements UserService {28public class GuestServiceImpl extends RemoteServiceServlet implements GuestService {
29
30 @Override
31 public User getCurrentUserDetails() throws ServerException {
32
33 UserGetter u = new UserGetter();
34 UserData ud = u.getCurrentUser();
35
36 return ModelWrapper.getClientCloneSafe(ud, ud.getRole(), ClientView.PRIVATE);
37 }
2638
27}39}
2840
=== modified file 'src/au/edu/unimelb/csse/mugle/shared/model/DataServiceAsync.java'
--- src/au/edu/unimelb/csse/mugle/shared/model/DataServiceAsync.java 2011-04-08 09:52:55 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/model/DataServiceAsync.java 2011-04-29 07:02:27 +0000
@@ -26,7 +26,7 @@
2626
27 void fetchDevTeams(Set<Long> keys, AsyncCallback<Set<DevTeam>> callback);27 void fetchDevTeams(Set<Long> keys, AsyncCallback<Set<DevTeam>> callback);
2828
29 void fetchGameFiles(Set<String> keys, AsyncCallback<Set<GameFile>> callback);29 void fetchGameFiles(Set<Long> keys, AsyncCallback<Set<GameFile>> callback);
3030
31 void fetchGames(Set<Long> keys, AsyncCallback<Set<Game>> callback);31 void fetchGames(Set<Long> keys, AsyncCallback<Set<Game>> callback);
3232
3333
=== modified file 'src/au/edu/unimelb/csse/mugle/shared/model/GameFile.java'
--- src/au/edu/unimelb/csse/mugle/shared/model/GameFile.java 2011-04-29 07:02:27 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/model/GameFile.java 2011-04-29 07:02:27 +0000
@@ -17,10 +17,6 @@
1717
18package au.edu.unimelb.csse.mugle.shared.model;18package au.edu.unimelb.csse.mugle.shared.model;
1919
20import java.util.Set;
21
22import com.google.gwt.user.client.rpc.AsyncCallback;
23
24import au.edu.unimelb.csse.mugle.shared.model.annotations.*;20import au.edu.unimelb.csse.mugle.shared.model.annotations.*;
2521
26@MugleDataWrapper22@MugleDataWrapper
@@ -36,11 +32,11 @@
3632
37 private String blobKey; //key to the actual blob33 private String blobKey; //key to the actual blob
38 34
39 private Set<Long> gameVersionKeys; //Game versions this file belongs to35 private GameVersion version; //Game versions this file belongs to
4036
41 // Constructors37 // Constructors
42 public GameFile() {38 public GameFile() {
43 this.gameVersionKeys = null;39 this.version = null;
44 this.mimeType = null;40 this.mimeType = null;
45 this.blobKey = null;41 this.blobKey = null;
46 this.path = null;42 this.path = null;
@@ -52,12 +48,8 @@
52 return this.path;48 return this.path;
53 }49 }
5450
55 public Set<Long> getGameVersionKeys() {51 public GameVersion getGameVersionKeys() {
56 return this.gameVersionKeys;52 return this.version;
57 }
58
59 public void fetchGameVersions(AsyncCallback<Set<GameVersion>> callback) {
60 DataProvider.getService().fetchGameVersions(this.gameVersionKeys, callback);
61 }53 }
62 54
63 @Override55 @Override
@@ -71,8 +63,8 @@
71 this.path = path;63 this.path = path;
72 }64 }
7365
74 public void setGameVersionKeys(Set<Long> versions) {66 public void setGameVersionKeys(GameVersion version) {
75 this.gameVersionKeys = versions;67 this.version = version;
76 }68 }
7769
78 public void setMimeType(String mimeType) {70 public void setMimeType(String mimeType) {
7971
=== modified file 'src/au/edu/unimelb/csse/mugle/shared/model/GameVersion.java'
--- src/au/edu/unimelb/csse/mugle/shared/model/GameVersion.java 2011-04-29 07:02:27 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/model/GameVersion.java 2011-04-29 07:02:27 +0000
@@ -49,7 +49,7 @@
4949
50 private PromotedGame promotedGame;50 private PromotedGame promotedGame;
5151
52 private Set<String> gameFileKeys;52 private Set<Long> gameFileKeys;
5353
54 // Constructors54 // Constructors
55 55
@@ -95,7 +95,7 @@
95 return this.promotedGame;95 return this.promotedGame;
96 }96 }
97 97
98 public Set<String> getGameFileKeys() {98 public Set<Long> getGameFileKeys() {
99 return this.gameFileKeys;99 return this.gameFileKeys;
100 }100 }
101 101
@@ -130,7 +130,7 @@
130 this.promotedGame = promotedGame;130 this.promotedGame = promotedGame;
131 }131 }
132132
133 public void setGameFileKeys(Set<String> gameFiles) {133 public void setGameFileKeys(Set<Long> gameFiles) {
134 this.gameFileKeys = gameFiles;134 this.gameFileKeys = gameFiles;
135 } 135 }
136 136
137137
=== modified file 'src/au/edu/unimelb/csse/mugle/shared/model/ModelClass.java'
--- src/au/edu/unimelb/csse/mugle/shared/model/ModelClass.java 2011-03-30 15:46:59 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/model/ModelClass.java 2011-04-29 07:02:27 +0000
@@ -19,17 +19,20 @@
1919
20import java.io.Serializable;20import java.io.Serializable;
2121
22import com.google.gwt.user.client.rpc.IsSerializable;
23
22/**24/**
23 * Base model class that should be extended by all shared model class entities.25 * Base model class that should be extended by all shared model class entities.
24 * @param <S> The primary key type26 * @param <S> The primary key type
25 * @param <T> The client class type (usually self type)27 * @param <T> The client class type (usually self type)
26 * @param <U> The server class type (usually the data counter part type)28 * @param <U> The server class type (usually the data counter part type)
27 */29 */
28@SuppressWarnings("serial")
29public abstract class ModelClass<S,T extends ModelClass<S,?>> implements Serializable {
30
3130
32 private S id = null;31public abstract class ModelClass<S,T extends ModelClass<S,?>> implements Serializable, IsSerializable {
32
33 private static final long serialVersionUID = -2271296896173152105L;
34
35 private S id = null;
33 36
34 /**37 /**
35 * The getter for the primary key38 * The getter for the primary key
3639
=== modified file 'src/au/edu/unimelb/csse/mugle/shared/model/Role.java'
--- src/au/edu/unimelb/csse/mugle/shared/model/Role.java 2011-03-10 04:56:07 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/model/Role.java 2011-04-29 07:02:27 +0000
@@ -18,5 +18,5 @@
18package au.edu.unimelb.csse.mugle.shared.model;18package au.edu.unimelb.csse.mugle.shared.model;
1919
20public enum Role { 20public enum Role {
21 USER, DEVELOPER, ADMIN; 21 NONE, GUEST, DEVELOPER, ADMIN;
22}22}
2323
=== modified file 'src/au/edu/unimelb/csse/mugle/shared/model/annotations/MugleDataWrapper.java'
--- src/au/edu/unimelb/csse/mugle/shared/model/annotations/MugleDataWrapper.java 2011-03-30 15:46:59 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/model/annotations/MugleDataWrapper.java 2011-04-29 07:02:27 +0000
@@ -31,10 +31,10 @@
31@Target(ElementType.TYPE)31@Target(ElementType.TYPE)
32@Retention(RetentionPolicy.RUNTIME)32@Retention(RetentionPolicy.RUNTIME)
33public @interface MugleDataWrapper {33public @interface MugleDataWrapper {
34 Role privateAdd() default Role.USER;34 Role privateAdd() default Role.GUEST;
35 Role privateUpdate() default Role.USER;35 Role privateUpdate() default Role.GUEST;
36 Role privateRemove() default Role.USER;36 Role privateRemove() default Role.GUEST;
37 Role publicAdd() default Role.USER;37 Role publicAdd() default Role.GUEST;
38 Role publicUpdate() default Role.USER;38 Role publicUpdate() default Role.GUEST;
39 Role publicRemove() default Role.USER;39 Role publicRemove() default Role.GUEST;
40}40}
4141
=== added file 'src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameFileNotExists.java'
--- src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameFileNotExists.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameFileNotExists.java 2011-04-29 07:02:27 +0000
@@ -0,0 +1,22 @@
1package au.edu.unimelb.csse.mugle.shared.platform.exceptions;
2
3public class GameFileNotExists extends Exception{
4
5 /**
6 *
7 */
8 private static final long serialVersionUID = 728229816363066583L;
9
10 public GameFileNotExists() {
11 super();
12 }
13
14 public GameFileNotExists(Long primaryKey) {
15 super("The gameFile with primary key " + primaryKey.toString() + " does not exist");
16 }
17
18 public GameFileNotExists(String gameName, String gameVersion, String path) {
19 super("The file " + path + " for the version " + gameVersion +
20 " of " + gameName + " does not Exist.");
21 }
22}
023
=== 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-04-29 07:02:27 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/GameNotExists.java 2011-04-29 07:02:27 +0000
@@ -46,5 +46,9 @@
46 public GameNotExists(Long id) {46 public GameNotExists(Long id) {
47 super("Game with ID '" + id + "' does not exist.");47 super("Game with ID '" + id + "' does not exist.");
48 }48 }
49
50 public GameNotExists(String dispVersion, String gameName) {
51 super("Game " + gameName + " does not have version " + dispVersion + ".");
52 }
49 53
50}54}
51\ No newline at end of file55\ No newline at end of file
5256
=== added file 'src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/ServerException.java'
--- src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/ServerException.java 1970-01-01 00:00:00 +0000
+++ src/au/edu/unimelb/csse/mugle/shared/platform/exceptions/ServerException.java 2011-04-29 07:02:27 +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 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 ServerException extends Exception implements Serializable {
23
24 private static final long serialVersionUID = -5641489622969459865L;
25
26 public ServerException() {
27 super();
28 }
29
30 public ServerException(final String msg) {
31 super(msg);
32 }
33
34}
035
=== modified file 'war/Mugle.css'
--- war/Mugle.css 2011-04-08 11:51:46 +0000
+++ war/Mugle.css 2011-04-29 07:02:27 +0000
@@ -1,7 +1,8 @@
1/** Add css rules here for your application. */1/** Add css rules here for your application. */
22
3body {3body {
4 min-width: 600px;4 min-width: 1000px;
5 background: white;
5}6}
67
7h1 {8h1 {
@@ -12,54 +13,103 @@
12 text-align: center;13 text-align: center;
13}14}
1415
16#container {
17 min-height: 100%;
18 width: 100%;
19 position: relative;
20 float: left;
21}
22
23/* HEADER */
24
15#user-panel-container {25#user-panel-container {
16 height: 25px;26 height: 25px;
17 border-bottom: #b6bac0 1px solid;27 border-bottom: #b6bac0 1px solid;
18 margin: 0;28 margin: 0;
19 padding: 0 5px;29 padding: 0;
20 background-color: #ffffff;30 background: white;
31 position: relative;
32 float: left;
33 width: 100%;
21}34}
2235
23#user-panel-title {36#user-panel-title {
24 height: 25px;37 height: 25px;
25 width:50px;38 width:50px;
26 margin: 0;39 margin: 5px 5px 0 5px;
27 padding: 0;40 padding: 0;
28 float: left;41 float: left;
29 padding-top: 5px;
30}42}
3143
32#user-panel-holder {44#user-panel-holder {
33 height: 25px;45 height: 25px;
34 margin: 0;46 margin: 0;
35 padding: 0;47 padding: 0 5px;
36 float: right;48 float: right;
37 text-align: : right;49 text-align: : right;
38}50}
3951
52/* BODY */
53
40#main-panel {54#main-panel {
41 text-align: center;55 padding:0;
42 min-height:500px;56 padding-bottom:100px; /* Height of the footer */
43 height:100%;57 background:white;
44 background-color: #ffffff;58 position: relative;
45}59 float: left;
46
47table#tools-panel {
48 position: absolute;
49 left: 0;
50 top: 25px;
51 width: 250px;
52}
53
54#error-display {
55 background-color: #ffffff;
56 width: 100%;60 width: 100%;
57}61}
5862
63#main-panel-container {
64 clear:left;
65 float:left;
66 width:100%;
67 overflow:hidden;
68 background:white; /* column 2 background colour */
69}
70
71#main-panel-container-inner {
72 float:left;
73 width:100%;
74 position:relative;
75 right:80%;
76 background:white; /* column 1 background colour */
77 border-right: #b6bac0 1px solid;
78 min-height: 500px;
79}
80
81#tools-panel {
82 float:left;
83 width:20%;
84 position:relative;
85 left:80%;
86 overflow:hidden;
87}
88
89#right-panel {
90 float:left;
91 width:80%;
92 position:relative;
93 left:80%;
94 overflow:hidden;
95}
96
97#right-panel-inner {
98 float:left;
99 width:100%;
100 margin:5px;
101}
102
103/* FOOTER */
104
59#footer {105#footer {
106 position:absolute;
107 /*position: relative;*/
108 width: 100%;
109 bottom: 0;
60 text-align: center;110 text-align: center;
61 background: #01467d url('img/footer-top.png') top center repeat-x;111 background: #01467d url('img/footer-top.png') top center repeat-x;
62 height: 100px;112 height: 100px; /* Height of the footer */
63}113}
64114
65#footer-banner {115#footer-banner {
@@ -80,6 +130,11 @@
80 float: right; 130 float: right;
81}131}
82132
133#error-display {
134 background-color: #ffffff;
135 width: 100%;
136}
137
83.sendButton {138.sendButton {
84 display: block;139 display: block;
85 font-size: 16pt;140 font-size: 16pt;
86141
=== modified file 'war/Mugle.html'
--- war/Mugle.html 2011-04-02 04:18:20 +0000
+++ war/Mugle.html 2011-04-29 07:02:27 +0000
@@ -30,7 +30,10 @@
30 <!-- Consider inlining CSS to reduce the number of requested files -->30 <!-- Consider inlining CSS to reduce the number of requested files -->
31 <!-- -->31 <!-- -->
32 <link type="text/css" rel="stylesheet" href="Mugle.css">32 <link type="text/css" rel="stylesheet" href="Mugle.css">
3333 <!--[if lte IE 6]>
34 <link type="text/css" rel="stylesheet" href="MugleIE6.css">
35 <![endif]-->
36
34 <!-- -->37 <!-- -->
35 <!-- Any title is fine -->38 <!-- Any title is fine -->
36 <!-- -->39 <!-- -->
@@ -62,28 +65,34 @@
62 </div>65 </div>
63 </noscript>66 </noscript>
64 67
65 <div id="user-panel-container">68 <div id="container">
66 <div id="user-panel-title"></div>69
67 <div id="user-panel-holder"></div>70 <div id="user-panel-container">
68 </div>71 <div id="user-panel-title"></div>
69 72 <div id="user-panel-holder"></div>
70 <div id="main-panel"></div>73 </div>
71 74
72 <table id="error-display" align="center"> 75 <div id="main-panel">
73 <tr>76 <!-- All GWT elements gets added/removed in here. -->
74 <td colspan="2" style="color:red;" id="errorLabelContainer"></td>77 </div>
75 </tr>78
76 </table>79 <table id="error-display" align="center">
77 80 <tr>
78 <div id="footer">81 <td colspan="2" style="color:red;" id="errorLabelContainer"></td>
79 <div id="footer-banner">82 </tr>
80 <a id="unimelb-logo" href="http://www.unimelb.edu.au" title="University of Melbourne" target="_blank">83 </table>
81 <img src="img/unimelb.png"></img>84
82 </a>85 <div id="footer">
83 <div id="footer-content">86 <div id="footer-banner">
84 <!-- Add copyright details, etc -->87 <a id="unimelb-logo" href="http://www.unimelb.edu.au" title="University of Melbourne" target="_blank">
85 </div>88 <img src="img/unimelb.png"></img>
86 </div>89 </a>
90 <div id="footer-content">
91 <!-- Add copyright details, etc -->
92 </div>
93 </div>
94 </div>
95
87 </div>96 </div>
88 97
89 </body>98 </body>
9099
=== added file 'war/MugleIE6.css'
--- war/MugleIE6.css 1970-01-01 00:00:00 +0000
+++ war/MugleIE6.css 2011-04-29 07:02:27 +0000
@@ -0,0 +1,3 @@
1#container {
2 height:100%;
3}
0\ No newline at end of file4\ No newline at end of file
15
=== modified file 'war/WEB-INF/web.xml'
--- war/WEB-INF/web.xml 2011-04-29 07:02:27 +0000
+++ war/WEB-INF/web.xml 2011-04-29 07:02:27 +0000
@@ -12,13 +12,13 @@
12 <!-- Servlets -->12 <!-- Servlets -->
13 13
14 <servlet>14 <servlet>
15 <servlet-name>LoginService</servlet-name>15 <servlet-name>ClientService</servlet-name>
16 <servlet-class>au.edu.unimelb.csse.mugle.server.LoginServiceImpl</servlet-class>16 <servlet-class>au.edu.unimelb.csse.mugle.server.ClientServiceImpl</servlet-class>
17 </servlet>17 </servlet>
1818
19 <servlet-mapping>19 <servlet-mapping>
20 <servlet-name>LoginService</servlet-name>20 <servlet-name>ClientService</servlet-name>
21 <url-pattern>/mugle/login</url-pattern>21 <url-pattern>/mugle/client</url-pattern>
22 </servlet-mapping>22 </servlet-mapping>
23 23
24 <servlet>24 <servlet>
@@ -52,13 +52,13 @@
52 </servlet-mapping>52 </servlet-mapping>
53 53
54 <servlet>54 <servlet>
55 <servlet-name>UserService</servlet-name>55 <servlet-name>GuestService</servlet-name>
56 <servlet-class>au.edu.unimelb.csse.mugle.server.platform.UserServiceImpl</servlet-class>56 <servlet-class>au.edu.unimelb.csse.mugle.server.platform.GuestServiceImpl</servlet-class>
57 </servlet>57 </servlet>
5858
59 <servlet-mapping>59 <servlet-mapping>
60 <servlet-name>UserService</servlet-name>60 <servlet-name>GuestService</servlet-name>
61 <url-pattern>/mugle/users</url-pattern>61 <url-pattern>/mugle/guests</url-pattern>
62 </servlet-mapping>62 </servlet-mapping>
63 63
64 <servlet>64 <servlet>

Subscribers

People subscribed via source and target branches