Skip to content
This repository was archived by the owner on Feb 18, 2024. It is now read-only.

Commit 46ec62f

Browse files
author
Yaniv Inbar
committed
Update calendar-appengine-sample and some others
http://codereview.appspot.com/5782054/
1 parent 370af5e commit 46ec62f

File tree

31 files changed

+267
-418
lines changed

31 files changed

+267
-418
lines changed

calendar-appengine-sample/.classpath

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
<classpath>
33
<classpathentry kind="src" path="src/main/java" />
44
<classpathentry kind="src" path="src/main/resources" />
5-
<classpathentry kind="con"
6-
path="com.google.appengine.eclipse.core.GAE_CONTAINER" />
5+
<classpathentry kind="src" path="src/main/webapp" />
76
<classpathentry kind="con"
87
path="com.google.gwt.eclipse.core.GWT_CONTAINER" />
98
<classpathentry kind="con"
109
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6" />
1110
<classpathentry kind="con"
12-
path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER" />
11+
path="com.google.appengine.eclipse.core.GAE_CONTAINER" />
1312
<classpathentry kind="output" path="target/war/WEB-INF/classes" />
13+
<classpathentry kind="con"
14+
path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER" />
1415
</classpath>
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
#Fri Nov 04 10:43:46 EDT 2011
1+
#Thu Mar 08 12:05:26 EST 2012
22
eclipse.preferences.version=1
3-
filesCopiedToWebInfLib=
3+
filesCopiedToWebInfLib=jsr107cache-1.1.jar|datanucleus-jpa-1.1.5.jar|datanucleus-appengine-1.0.10.final.jar|datanucleus-core-1.1.5.jar|geronimo-jpa_3.0_spec-1.1.1.jar|geronimo-jta_1.1_spec-1.1.1.jar|jdo2-api-2.3-eb.jar|appengine-api-labs-1.6.3.jar|appengine-api-1.0-sdk-1.6.3.jar|appengine-jsr107cache-1.6.3.jar
4+
gaeDeployDialogSettings=
5+
gaeIsEclipseDefaultInstPath=true
6+
googleCloudSqlEnabled=false
7+
localDevMySqlEnabled=true

calendar-appengine-sample/instructions.html

+1-7
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,8 @@ <h3>Checkout Instructions</h3>
3434

3535
<pre><code>cd <i>[someDirectory]</i>
3636
hg clone https://code.google.com/p/google-api-java-client.samples/ google-api-java-client-samples
37-
cd google-api-java-client-samples/shared/shared-sample-appengine
37+
cd google-api-java-client-samples/calendar-appengine-sample
3838
<i>[editor]</i> src/main/resources/client_secrets.json
39-
mvn source:jar install
40-
cd ../gdata/shared-sample-gdata
41-
mvn source:jar install
42-
cd ../shared-sample-calendar
43-
mvn source:jar install
44-
cd ../../../calendar-appengine-sample
4539
mvn clean package</code></pre>
4640

4741
<h3>Setup Project in Eclipse 3.5/3.6</h3>

calendar-appengine-sample/pom.xml

+58-18
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<groupId>com.google.apis-samples</groupId>
1111
<artifactId>calendar-appengine-sample</artifactId>
1212
<version>1.1.0</version>
13-
<name>Example for the Google Calendar Data API v2 using Atom and OAuth 2 on Google App Engine.</name>
13+
<name>Example for the Google Calendar Data API v3 using OAuth 2 on Google App Engine.</name>
1414
<packaging>war</packaging>
1515

1616
<url>http://code.google.com/p/google-api-java-client/</url>
@@ -61,9 +61,9 @@
6161

6262
<properties>
6363
<datanucleus.version>1.1.5</datanucleus.version>
64-
<gae.version>1.5.5</gae.version>
65-
<gwt.version>2.1.1</gwt.version>
66-
<google-api-client.version>1.6.0-beta</google-api-client.version>
64+
<gae.version>1.6.3</gae.version>
65+
<gwt.version>2.4.0</gwt.version>
66+
<google-api-client.version>1.7.0-beta</google-api-client.version>
6767
<webappDirectory>${project.build.directory}/${project.build.finalName}
6868
</webappDirectory>
6969
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -101,7 +101,7 @@
101101
<plugin>
102102
<groupId>org.codehaus.mojo</groupId>
103103
<artifactId>gwt-maven-plugin</artifactId>
104-
<version>2.1.0-1</version>
104+
<version>2.4.0</version>
105105
<executions>
106106
<execution>
107107
<goals>
@@ -159,10 +159,7 @@
159159
<artifactId>datanucleus-enhancer</artifactId>
160160
<version>1.1.4</version>
161161
</dependency>
162-
<!--
163-
Dependency added as workaround to GWT Issue 5947 for details see
164-
http://code.google.com/p/google-web-toolkit/issues/detail?id=5497
165-
-->
162+
<!-- Dependency added as workaround to GWT Issue 5947 for details see http://code.google.com/p/google-web-toolkit/issues/detail?id=5497 -->
166163
<dependency>
167164
<groupId>javax.jdo</groupId>
168165
<artifactId>jdo2-api</artifactId>
@@ -220,17 +217,55 @@
220217
</executions>
221218
</plugin>
222219
</plugins>
220+
<pluginManagement>
221+
<plugins>
222+
<!--This plugin's configuration is used to store Eclipse m2e settings only.
223+
It has no influence on the Maven build itself. -->
224+
<plugin>
225+
<groupId>org.eclipse.m2e</groupId>
226+
<artifactId>lifecycle-mapping</artifactId>
227+
<version>1.0.0</version>
228+
<configuration>
229+
<lifecycleMappingMetadata>
230+
<pluginExecutions>
231+
<pluginExecution>
232+
<pluginExecutionFilter>
233+
<groupId>org.apache.maven.plugins</groupId>
234+
<artifactId>maven-war-plugin</artifactId>
235+
<versionRange>[2.1.1,)</versionRange>
236+
<goals>
237+
<goal>exploded</goal>
238+
</goals>
239+
</pluginExecutionFilter>
240+
<action>
241+
<ignore></ignore>
242+
</action>
243+
</pluginExecution>
244+
<pluginExecution>
245+
<pluginExecutionFilter>
246+
<groupId>org.datanucleus</groupId>
247+
<artifactId>maven-datanucleus-plugin</artifactId>
248+
<versionRange>[1.1.4,)</versionRange>
249+
<goals>
250+
<goal>enhance</goal>
251+
</goals>
252+
</pluginExecutionFilter>
253+
<action>
254+
<ignore></ignore>
255+
</action>
256+
</pluginExecution>
257+
</pluginExecutions>
258+
</lifecycleMappingMetadata>
259+
</configuration>
260+
</plugin>
261+
</plugins>
262+
</pluginManagement>
223263
</build>
224264
<dependencies>
225265
<dependency>
226-
<groupId>com.google.apis-samples</groupId>
227-
<artifactId>shared-sample-appengine</artifactId>
228-
<version>1.1.0</version>
229-
</dependency>
230-
<dependency>
231-
<groupId>com.google.apis-samples</groupId>
232-
<artifactId>shared-sample-calendar</artifactId>
233-
<version>v2-1.1.0</version>
266+
<groupId>com.google.apis</groupId>
267+
<artifactId>google-api-services-calendar</artifactId>
268+
<version>v3-rev2-1.4.0-beta</version>
234269
</dependency>
235270
<dependency>
236271
<groupId>net.kindleit</groupId>
@@ -240,14 +275,19 @@
240275
</dependency>
241276
<dependency>
242277
<groupId>com.google.api-client</groupId>
243-
<artifactId>google-api-client-extensions</artifactId>
278+
<artifactId>google-api-client-appengine</artifactId>
244279
<version>${google-api-client.version}</version>
245280
</dependency>
246281
<dependency>
247282
<groupId>com.google.gwt</groupId>
248283
<artifactId>gwt-user</artifactId>
249284
<version>${gwt.version}</version>
250285
</dependency>
286+
<dependency>
287+
<groupId>com.google.gwt</groupId>
288+
<artifactId>gwt-servlet</artifactId>
289+
<version>${gwt.version}</version>
290+
</dependency>
251291
<dependency>
252292
<groupId>net.sf.jsr107cache</groupId>
253293
<artifactId>jsr107cache</artifactId>

calendar-appengine-sample/src/main/java/com/google/api/services/samples/calendar/appengine/client/CalendarGwtSample.java

-3
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,11 @@ void refreshTable() {
6666
FlexTable calendarsTable = calendarsFrame.calendarsTable;
6767
calendarsTable.removeAllRows();
6868
calendarsTable.setText(0, 1, "Calendar Title");
69-
calendarsTable.setText(0, 2, "Updated");
7069
calendarsTable.getCellFormatter().addStyleName(0, 1, "methodsHeaderRow");
71-
calendarsTable.getCellFormatter().addStyleName(0, 2, "methodsHeaderRow");
7270
for (int i = 0; i < calendars.size(); i++) {
7371
GwtCalendar calendar = calendars.get(i);
7472
calendarsTable.setWidget(i + 1, 0, new CalendarButtons(this, calendar, i));
7573
calendarsTable.setText(i + 1, 1, calendar.title);
76-
calendarsTable.setText(i + 1, 2, calendar.updated);
7774
}
7875
}
7976

calendar-appengine-sample/src/main/java/com/google/api/services/samples/calendar/appengine/client/CalendarService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ public interface CalendarService extends RemoteService {
3535

3636
GwtCalendar insert(GwtCalendar calendar) throws IOException;
3737

38-
GwtCalendar update(GwtCalendar original, GwtCalendar updated) throws IOException;
38+
GwtCalendar update(GwtCalendar updated) throws IOException;
3939
}

calendar-appengine-sample/src/main/java/com/google/api/services/samples/calendar/appengine/client/CalendarServiceAsync.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ public interface CalendarServiceAsync {
3131

3232
void insert(GwtCalendar calendar, AsyncCallback<GwtCalendar> callback);
3333

34-
void update(GwtCalendar original, GwtCalendar updated, AsyncCallback<GwtCalendar> callback);
34+
void update(GwtCalendar updated, AsyncCallback<GwtCalendar> callback);
3535
}

calendar-appengine-sample/src/main/java/com/google/api/services/samples/calendar/appengine/client/UpdateDialogContent.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,9 @@ interface MyUiBinder extends UiBinder<HorizontalPanel, UpdateDialogContent> {
7070
void handleUpdate(ClickEvent e) {
7171
dialogBox.hide();
7272
GwtCalendar updated = new GwtCalendar();
73-
updated.editLink = calendar.editLink;
73+
updated.id = calendar.id;
7474
updated.title = textBox.getText();
75-
updated.updated = calendar.updated;
76-
CalendarGwtSample.SERVICE.update(calendar, updated, new AsyncCallback<GwtCalendar>() {
75+
CalendarGwtSample.SERVICE.update(updated, new AsyncCallback<GwtCalendar>() {
7776

7877
@Override
7978
public void onFailure(Throwable caught) {

calendar-appengine-sample/src/main/java/com/google/api/services/samples/calendar/appengine/server/CalendarAppEngineRequestInitializer.java

-52
This file was deleted.

calendar-appengine-sample/src/main/java/com/google/api/services/samples/calendar/appengine/server/CalendarAppEngineSample.java

+16-43
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,14 @@
1414

1515
package com.google.api.services.samples.calendar.appengine.server;
1616

17-
import com.google.api.client.extensions.auth.helpers.ThreeLeggedFlow;
18-
import com.google.api.client.extensions.servlet.auth.AbstractFlowUserServlet;
19-
import com.google.api.client.googleapis.extensions.auth.helpers.oauth2.draft10.GoogleOAuth2ThreeLeggedFlow;
20-
import com.google.api.client.http.HttpTransport;
21-
import com.google.api.client.json.JsonFactory;
22-
import com.google.api.services.calendar.CalendarUrl;
23-
import com.google.api.services.samples.shared.appengine.AppEngineUtils;
24-
import com.google.api.services.samples.shared.appengine.OAuth2ClientCredentials;
17+
import com.google.api.client.auth.oauth2.AuthorizationCodeFlow;
18+
import com.google.api.client.extensions.appengine.auth.oauth2.AbstractAppEngineAuthorizationCodeServlet;
2519
import com.google.appengine.api.users.UserService;
2620
import com.google.appengine.api.users.UserServiceFactory;
2721

2822
import java.io.IOException;
2923
import java.io.PrintWriter;
3024

31-
import javax.jdo.PersistenceManagerFactory;
3225
import javax.servlet.ServletException;
3326
import javax.servlet.http.HttpServletRequest;
3427
import javax.servlet.http.HttpServletResponse;
@@ -38,66 +31,46 @@
3831
*
3932
* @author Yaniv Inbar
4033
*/
41-
public class CalendarAppEngineSample extends AbstractFlowUserServlet {
34+
public class CalendarAppEngineSample extends AbstractAppEngineAuthorizationCodeServlet {
35+
4236
static final String APP_NAME = "Google Calendar Data API Sample Web Client";
4337

4438
static final String GWT_MODULE_NAME = "calendar";
4539

4640
private static final long serialVersionUID = 1L;
4741

4842
@Override
49-
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
43+
protected void doGet(HttpServletRequest request, HttpServletResponse response)
44+
throws IOException {
5045
response.setContentType("text/html");
5146
response.setCharacterEncoding("UTF-8");
5247
PrintWriter writer = response.getWriter();
5348
writer.println("<!doctype html><html><head>");
5449
writer.println("<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">");
5550
writer.println("<title>" + APP_NAME + "</title>");
56-
writer.println("<link type=\"text/css\" rel=\"stylesheet\" href=\"" + GWT_MODULE_NAME
57-
+ ".css\">");
51+
writer.println(
52+
"<link type=\"text/css\" rel=\"stylesheet\" href=\"" + GWT_MODULE_NAME + ".css\">");
5853
writer.println("<script type=\"text/javascript\" language=\"javascript\" " + "src=\""
5954
+ GWT_MODULE_NAME + "/" + GWT_MODULE_NAME + ".nocache.js\"></script>");
6055
writer.println("</head><body>");
6156
UserService userService = UserServiceFactory.getUserService();
6257
writer.println("<div class=\"header\"><b>" + request.getUserPrincipal().getName() + "</b> | "
63-
+ "<a href=\"" + userService.createLogoutURL(Utils.getFullURL(request))
58+
+ "<a href=\"" + userService.createLogoutURL(request.getRequestURL().toString())
6459
+ "\">Log out</a> | "
65-
+ "<a href=\"http://code.google.com/p/google-api-java-client/source/browse?repo="
66-
+ "samples#hg/calendar-appengine-sample\">See source code for " + "this sample</a></div>");
60+
+ "<a href=\"http://code.google.com/p/google-api-java-client/source/browse"
61+
+ "/calendar-appengine-sample?repo=samples\">See source code for "
62+
+ "this sample</a></div>");
6763
writer.println("<div id=\"main\"/>");
6864
writer.println("</body></html>");
6965
}
7066

7167
@Override
72-
protected PersistenceManagerFactory getPersistenceManagerFactory() {
73-
return AppEngineUtils.getPersistenceManagerFactory();
74-
}
75-
76-
@Override
77-
protected ThreeLeggedFlow newFlow(String userId) throws IOException {
78-
return new GoogleOAuth2ThreeLeggedFlow(userId, OAuth2ClientCredentials.getClientId(),
79-
OAuth2ClientCredentials.getClientSecret(), CalendarUrl.ROOT_URL, Utils.getCallbackUrl());
80-
}
81-
82-
@Override
83-
protected void service(HttpServletRequest req, HttpServletResponse resp) throws IOException,
84-
ServletException {
85-
Utils.setCallbackUrl(req);
86-
super.service(req, resp);
87-
}
88-
89-
@Override
90-
protected String getUserId() {
91-
return Utils.getUserId();
92-
}
93-
94-
@Override
95-
protected HttpTransport newHttpTransportInstance() {
96-
return AppEngineUtils.getHttpTransport();
68+
protected String getRedirectUri(HttpServletRequest req) throws ServletException, IOException {
69+
return Utils.getRedirectUri(req);
9770
}
9871

9972
@Override
100-
protected JsonFactory newJsonFactoryInstance() {
101-
return AppEngineUtils.getJsonFactory();
73+
protected AuthorizationCodeFlow initializeFlow() throws IOException {
74+
return Utils.newFlow();
10275
}
10376
}

0 commit comments

Comments
 (0)