forked from Connorhd/TabCloud
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add google app engine java source, added license file.
- Loading branch information
Showing
45 changed files
with
552 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (c) 2010 Connor Dunn | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
Tabcloud | ||
|
||
Chrome extension in folder "chrome" | ||
Chrome extension in folder "chrome" | ||
|
||
Google App Engine Java eclipse project in folder "appengine-java" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="com.google.appengine.eclipse.core.GAE_CONTAINER"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="output" path="war/WEB-INF/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>TabCloud</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>com.google.gdt.eclipse.core.webAppProjectValidator</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>com.google.appengine.eclipse.core.enhancerbuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>com.google.appengine.eclipse.core.projectValidator</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>com.google.appengine.eclipse.core.gaeNature</nature> | ||
</natures> | ||
</projectDescription> |
3 changes: 3 additions & 0 deletions
3
appengine-java/.settings/com.google.appengine.eclipse.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#Sat Aug 21 20:14:19 BST 2010 | ||
eclipse.preferences.version=1 | ||
filesCopiedToWebInfLib=appengine-api-1.0-sdk-1.3.4.jar|appengine-api-labs-1.3.4.jar|appengine-jsr107cache-1.3.4.jar|jsr107cache-1.1.jar|datanucleus-appengine-1.0.7.final.jar|datanucleus-core-1.1.5.jar|datanucleus-jpa-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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#Sat Aug 21 20:14:18 BST 2010 | ||
eclipse.preferences.version=1 | ||
warSrcDir=war | ||
warSrcDirIsOutput=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig"> | ||
|
||
<persistence-manager-factory name="transactions-optional"> | ||
<property name="javax.jdo.PersistenceManagerFactoryClass" | ||
value="org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManagerFactory"/> | ||
<property name="javax.jdo.option.ConnectionURL" value="appengine"/> | ||
<property name="javax.jdo.option.NontransactionalRead" value="true"/> | ||
<property name="javax.jdo.option.NontransactionalWrite" value="true"/> | ||
<property name="javax.jdo.option.RetainValues" value="true"/> | ||
<property name="datanucleus.appengine.autoCreateDatastoreTxns" value="true"/> | ||
</persistence-manager-factory> | ||
</jdoconfig> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# A default log4j configuration for log4j users. | ||
# | ||
# To use this configuration, deploy it into your application's WEB-INF/classes | ||
# directory. You are also encouraged to edit it as you like. | ||
|
||
# Configure the console as our one appender | ||
log4j.appender.A1=org.apache.log4j.ConsoleAppender | ||
log4j.appender.A1.layout=org.apache.log4j.PatternLayout | ||
log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%c] - %m%n | ||
|
||
# tighten logging on the DataNucleus Categories | ||
log4j.category.DataNucleus.JDO=WARN, A1 | ||
log4j.category.DataNucleus.Persistence=WARN, A1 | ||
log4j.category.DataNucleus.Cache=WARN, A1 | ||
log4j.category.DataNucleus.MetaData=WARN, A1 | ||
log4j.category.DataNucleus.General=WARN, A1 | ||
log4j.category.DataNucleus.Utility=WARN, A1 | ||
log4j.category.DataNucleus.Transaction=WARN, A1 | ||
log4j.category.DataNucleus.Datastore=WARN, A1 | ||
log4j.category.DataNucleus.ClassLoading=WARN, A1 | ||
log4j.category.DataNucleus.Plugin=WARN, A1 | ||
log4j.category.DataNucleus.ValueGeneration=WARN, A1 | ||
log4j.category.DataNucleus.Enhancer=WARN, A1 | ||
log4j.category.DataNucleus.SchemaTool=WARN, A1 |
53 changes: 53 additions & 0 deletions
53
appengine-java/src/uk/co/connorhd/tabcloud/AddServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package uk.co.connorhd.tabcloud; | ||
|
||
import java.io.IOException; | ||
|
||
import javax.jdo.PersistenceManager; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import com.google.appengine.api.datastore.Key; | ||
import com.google.appengine.api.datastore.KeyFactory; | ||
import com.google.appengine.api.users.User; | ||
import com.google.appengine.api.users.UserService; | ||
import com.google.appengine.api.users.UserServiceFactory; | ||
|
||
@SuppressWarnings("serial") | ||
public class AddServlet extends HttpServlet { | ||
public void doPost(HttpServletRequest req, HttpServletResponse resp) | ||
throws IOException { | ||
UserService userService = UserServiceFactory.getUserService(); | ||
User user = userService.getCurrentUser(); | ||
|
||
if (user != null) { | ||
PersistenceManager pm = PMF.get().getPersistenceManager(); | ||
TCUser tcUser; | ||
try { | ||
// Get user | ||
Key k = KeyFactory.createKey(TCUser.class.getSimpleName(), user.getEmail()); | ||
tcUser = pm.getObjectById(TCUser.class, k); | ||
tcUser.addWindow(req.getParameter("window")); | ||
try { | ||
pm.makePersistent(tcUser); | ||
} finally { | ||
pm.close(); | ||
} | ||
} catch (Exception e) { | ||
// New user | ||
tcUser = new TCUser(user); | ||
tcUser.addWindow(req.getParameter("window")); | ||
try { | ||
pm.makePersistent(tcUser); | ||
} finally { | ||
pm.close(); | ||
} | ||
} | ||
resp.setContentType("text/plain"); | ||
resp.getWriter().println("{\"status\": \"loggedin\"}"); | ||
} else { | ||
resp.setContentType("text/json"); | ||
resp.getWriter().println("{\"status\": \"loggedout\"}"); | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
appengine-java/src/uk/co/connorhd/tabcloud/LoginServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package uk.co.connorhd.tabcloud; | ||
|
||
import java.io.IOException; | ||
import javax.servlet.http.*; | ||
import com.google.appengine.api.users.User; | ||
import com.google.appengine.api.users.UserService; | ||
import com.google.appengine.api.users.UserServiceFactory; | ||
|
||
@SuppressWarnings("serial") | ||
public class LoginServlet extends HttpServlet { | ||
public void doGet(HttpServletRequest req, HttpServletResponse resp) | ||
throws IOException { | ||
UserService userService = UserServiceFactory.getUserService(); | ||
User user = userService.getCurrentUser(); | ||
|
||
if (user != null) { | ||
resp.setContentType("text/html"); | ||
resp.getWriter().println("<html><head><link rel=\"icon\" type=\"image/png\" href=\"images/icon16.png\"><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"><title>TabCloud</title></head><body><div style=\"margin: 40px auto; width: 600px;\"><img style=\"float: left; padding-right: 20px;\" src=\"images/tabcloud200.png\" alt=\"TabCloud\" /><div style=\"font-family:sans-serif; font-size: 1.8em; text-align: center; padding-top: 50px;\"><strong>You are now logged in.</strong><br />Click the TabCloud menu icon to access TabCloud.</div></div></body></html>"); | ||
} else { | ||
resp.sendRedirect(userService.createLoginURL(req.getRequestURI())); | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
appengine-java/src/uk/co/connorhd/tabcloud/LogoutServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package uk.co.connorhd.tabcloud; | ||
|
||
import java.io.IOException; | ||
import javax.servlet.http.*; | ||
import com.google.appengine.api.users.User; | ||
import com.google.appengine.api.users.UserService; | ||
import com.google.appengine.api.users.UserServiceFactory; | ||
|
||
@SuppressWarnings("serial") | ||
public class LogoutServlet extends HttpServlet { | ||
public void doGet(HttpServletRequest req, HttpServletResponse resp) | ||
throws IOException { | ||
UserService userService = UserServiceFactory.getUserService(); | ||
User user = userService.getCurrentUser(); | ||
|
||
if (user == null) { | ||
resp.setContentType("text/html"); | ||
resp.getWriter().println("<html><head><link rel=\"icon\" type=\"image/png\" href=\"images/icon16.png\"><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"><title>TabCloud</title></head><body><div style=\"margin: 40px auto; width: 600px;\"><img style=\"float: left; padding-right: 20px;\" src=\"images/tabcloud200.png\" alt=\"TabCloud\" /><div style=\"font-family:sans-serif; font-size: 1.8em; text-align: center; padding-top: 50px;\"><strong>You are now logged out.</strong><br />You will have to login again to access your saved windows on TabCloud.</div></div></body></html>"); | ||
} else { | ||
resp.sendRedirect(userService.createLogoutURL(req.getRequestURI())); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package uk.co.connorhd.tabcloud; | ||
|
||
import javax.jdo.JDOHelper; | ||
import javax.jdo.PersistenceManagerFactory; | ||
|
||
public final class PMF { | ||
private static final PersistenceManagerFactory pmfInstance = | ||
JDOHelper.getPersistenceManagerFactory("transactions-optional"); | ||
|
||
private PMF() {} | ||
|
||
public static PersistenceManagerFactory get() { | ||
return pmfInstance; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
appengine-java/src/uk/co/connorhd/tabcloud/RemoveServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package uk.co.connorhd.tabcloud; | ||
|
||
import java.io.IOException; | ||
|
||
import javax.jdo.PersistenceManager; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import com.google.appengine.api.datastore.Key; | ||
import com.google.appengine.api.datastore.KeyFactory; | ||
import com.google.appengine.api.users.User; | ||
import com.google.appengine.api.users.UserService; | ||
import com.google.appengine.api.users.UserServiceFactory; | ||
|
||
@SuppressWarnings("serial") | ||
public class RemoveServlet extends HttpServlet { | ||
public void doPost(HttpServletRequest req, HttpServletResponse resp) | ||
throws IOException { | ||
UserService userService = UserServiceFactory.getUserService(); | ||
User user = userService.getCurrentUser(); | ||
|
||
if (user != null) { | ||
PersistenceManager pm = PMF.get().getPersistenceManager(); | ||
TCUser tcUser; | ||
try { | ||
// Get user | ||
Key k = KeyFactory.createKey(TCUser.class.getSimpleName(), user.getEmail()); | ||
tcUser = pm.getObjectById(TCUser.class, k); | ||
tcUser.removeWindow(Integer.parseInt(req.getParameter("window"))); | ||
try { | ||
pm.makePersistent(tcUser); | ||
} finally { | ||
pm.close(); | ||
} | ||
} catch (Exception e) { | ||
// New user | ||
pm.close(); | ||
} | ||
resp.setContentType("text/plain"); | ||
resp.getWriter().println("{\"status\": \"loggedin\"}"); | ||
} else { | ||
resp.setContentType("text/json"); | ||
resp.getWriter().println("{\"status\": \"loggedout\"}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package uk.co.connorhd.tabcloud; | ||
|
||
import java.util.Vector; | ||
|
||
import javax.jdo.annotations.Extension; | ||
import javax.jdo.annotations.IdGeneratorStrategy; | ||
import javax.jdo.annotations.PersistenceCapable; | ||
import javax.jdo.annotations.Persistent; | ||
import javax.jdo.annotations.PrimaryKey; | ||
|
||
import com.google.appengine.api.datastore.KeyFactory; | ||
import com.google.appengine.api.datastore.Text; | ||
import com.google.appengine.api.users.User; | ||
|
||
@PersistenceCapable | ||
public class TCUser { | ||
@SuppressWarnings("unused") | ||
@PrimaryKey | ||
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) | ||
@Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true") | ||
private String encodedKey; | ||
|
||
@Persistent | ||
private Vector<Text> window; | ||
|
||
public TCUser(User user) { | ||
this.encodedKey = KeyFactory.keyToString(KeyFactory.createKey(TCUser.class.getSimpleName(), user.getEmail())); | ||
this.window = new Vector<Text>(); | ||
} | ||
|
||
public Vector<Text> getWindows() { | ||
return this.window; | ||
} | ||
|
||
public void addWindow(String str) { | ||
this.window.add(new Text(str)); | ||
} | ||
|
||
public void updateWindow(int index, String str) { | ||
this.window.remove(index); | ||
this.window.add(index, new Text(str)); | ||
} | ||
|
||
public void removeWindow(int index) { | ||
this.window.remove(index); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
appengine-java/src/uk/co/connorhd/tabcloud/TabCloudServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package uk.co.connorhd.tabcloud; | ||
|
||
import java.io.IOException; | ||
|
||
import javax.jdo.PersistenceManager; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import com.google.appengine.api.datastore.Key; | ||
import com.google.appengine.api.datastore.KeyFactory; | ||
import com.google.appengine.api.datastore.Text; | ||
import com.google.appengine.api.users.User; | ||
import com.google.appengine.api.users.UserService; | ||
import com.google.appengine.api.users.UserServiceFactory; | ||
|
||
@SuppressWarnings("serial") | ||
public class TabCloudServlet extends HttpServlet { | ||
public void doGet(HttpServletRequest req, HttpServletResponse resp) | ||
throws IOException { | ||
UserService userService = UserServiceFactory.getUserService(); | ||
User user = userService.getCurrentUser(); | ||
|
||
if (user != null) { | ||
PersistenceManager pm = PMF.get().getPersistenceManager(); | ||
TCUser tcUser; | ||
try { | ||
// Get user | ||
Key k = KeyFactory.createKey(TCUser.class.getSimpleName(), user.getEmail()); | ||
tcUser = pm.getObjectById(TCUser.class, k); | ||
|
||
} catch (Exception e) { | ||
// New user | ||
tcUser = new TCUser(user); | ||
try { | ||
pm.makePersistent(tcUser); | ||
} finally { | ||
|
||
} | ||
} | ||
String windowString = ""; | ||
for (Text text : tcUser.getWindows()) { | ||
windowString += text.getValue()+","; | ||
} | ||
if (windowString != "") | ||
windowString = windowString.substring(0, windowString.length()-1); | ||
pm.close(); | ||
resp.setContentType("text/plain"); | ||
resp.getWriter().println("{\"status\": \"loggedin\", \"windows\": ["+windowString+"]}"); | ||
} else { | ||
resp.setContentType("text/json"); | ||
resp.getWriter().println("{\"status\": \"loggedout\"}"); | ||
} | ||
} | ||
} |
Oops, something went wrong.