diff --git a/.classpath b/.classpath index 698778fe..08532bce 100644 --- a/.classpath +++ b/.classpath @@ -17,12 +17,18 @@ - + + - + + + + + + diff --git a/.project b/.project index 8311b9d6..6d5224a3 100644 --- a/.project +++ b/.project @@ -20,11 +20,16 @@ - - org.eclipse.wst.validation.validationbuilder - - - + + org.eclipse.wst.validation.validationbuilder + + + + + org.hibernate.eclipse.console.hibernateBuilder + + + org.eclipse.m2e.core.maven2Builder @@ -38,5 +43,6 @@ org.eclipse.wst.jsdt.core.jsNature org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature + org.hibernate.eclipse.console.hibernateNature diff --git a/.settings/oracle.eclipse.tools.webtier.ui.prefs b/.settings/oracle.eclipse.tools.webtier.ui.prefs new file mode 100644 index 00000000..b0107e52 --- /dev/null +++ b/.settings/oracle.eclipse.tools.webtier.ui.prefs @@ -0,0 +1,5 @@ +_hiddenCategory_\:HTML=false +_hiddenCategory_\:ManagedBeans=false +_hiddenCategory_\:PageVariables=false +_hiddenCategory_\:jsp11=false +eclipse.preferences.version=1 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index ff57fc10..d46a7d7b 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,14 +1,16 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 0bca5d83..fff2c35f 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -3,7 +3,9 @@ + + - + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml index 19a347a2..069f1ccb 100644 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -1,10 +1,10 @@ - + - - + + diff --git a/.settings/org.eclipse.wst.validation.prefs b/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 00000000..04cad8cb --- /dev/null +++ b/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,2 @@ +disabled=06target +eclipse.preferences.version=1 diff --git a/.settings/org.hibernate.eclipse.console.prefs b/.settings/org.hibernate.eclipse.console.prefs index 0ce46f8d..efd7b958 100644 --- a/.settings/org.hibernate.eclipse.console.prefs +++ b/.settings/org.hibernate.eclipse.console.prefs @@ -1,4 +1,3 @@ -#Thu Jan 12 14:12:39 PST 2012 -default.configuration= +default.configuration=pyx eclipse.preferences.version=1 -hibernate3.enabled=false +hibernate3.enabled=true diff --git a/.tern-project b/.tern-project new file mode 100644 index 00000000..3965203e --- /dev/null +++ b/.tern-project @@ -0,0 +1 @@ +{"libs":["ecma5","browser"],"plugins":{"guess-types":{},"outline":{}},"ide":{}} \ No newline at end of file diff --git a/WebContent/js/cah.constants.js b/WebContent/js/cah.constants.js index 54728373..918151c7 100644 --- a/WebContent/js/cah.constants.js +++ b/WebContent/js/cah.constants.js @@ -62,7 +62,7 @@ cah.$.GameInfo.STATE = "S"; cah.$.GameInfo.ID = "gid"; cah.$.GameInfo.HAS_PASSWORD = "hp"; -cah.$.GameState = function() { +cah.$.AjaxRequest = function() { // Dummy constructor to make Eclipse auto-complete. }; cah.$.GameState.prototype.dummyForAutocomplete = undefined; @@ -78,7 +78,7 @@ cah.$.GameState_msg['j'] = "In Progress"; cah.$.GameState_msg['l'] = "Not Started"; cah.$.GameState_msg['ro'] = "In Progress"; -cah.$.CardSetData = function() { +cah.$.AjaxResponse = function() { // Dummy constructor to make Eclipse auto-complete. }; cah.$.CardSetData.prototype.dummyForAutocomplete = undefined; @@ -109,7 +109,7 @@ cah.$.WhiteCardData.TEXT = "T"; cah.$.WhiteCardData.ID = "cid"; cah.$.WhiteCardData.WATERMARK = "W"; -cah.$.LongPollResponse = function() { +cah.$.CardSetData = function() { // Dummy constructor to make Eclipse auto-complete. }; cah.$.LongPollResponse.prototype.dummyForAutocomplete = undefined; @@ -137,7 +137,7 @@ cah.$.LongPollResponse.ERROR = "e"; cah.$.LongPollResponse.INTERMISSION = "i"; cah.$.LongPollResponse.REASON = "qr"; -cah.$.LongPollEvent = function() { +cah.$.DisconnectReason = function() { // Dummy constructor to make Eclipse auto-complete. }; cah.$.LongPollEvent.prototype.dummyForAutocomplete = undefined; @@ -259,7 +259,7 @@ cah.$.ErrorInformation.WHITE_CARDS_REQUIRED = "wcr"; cah.$.ErrorInformation.BLACK_CARDS_REQUIRED = "bcr"; cah.$.ErrorInformation.BLACK_CARDS_PRESENT = "bcp"; -cah.$.AjaxResponse = function() { +cah.$.GameInfo = function() { // Dummy constructor to make Eclipse auto-complete. }; cah.$.AjaxResponse.prototype.dummyForAutocomplete = undefined; @@ -282,7 +282,7 @@ cah.$.AjaxResponse.CARD_ID = "cid"; cah.$.AjaxResponse.ERROR = "e"; cah.$.AjaxResponse.CARD_SETS = "css"; -cah.$.AjaxRequest = function() { +cah.$.GameOptionData = function() { // Dummy constructor to make Eclipse auto-complete. }; cah.$.AjaxRequest.prototype.dummyForAutocomplete = undefined; @@ -298,7 +298,7 @@ cah.$.AjaxRequest.CARD_ID = "cid"; cah.$.AjaxRequest.CARDCAST_ID = "cci"; cah.$.AjaxRequest.GAME_ID = "gid"; -cah.$.AjaxOperation = function() { +cah.$.GamePlayerInfo = function() { // Dummy constructor to make Eclipse auto-complete. }; cah.$.AjaxOperation.prototype.dummyForAutocomplete = undefined; @@ -335,7 +335,7 @@ cah.$.ReconnectNextAction.prototype.dummyForAutocomplete = undefined; cah.$.ReconnectNextAction.GAME = "game"; cah.$.ReconnectNextAction.NONE = "none"; -cah.$.DisconnectReason = function() { +cah.$.WhiteCardData = function() { // Dummy constructor to make Eclipse auto-complete. }; cah.$.DisconnectReason.prototype.dummyForAutocomplete = undefined; @@ -344,4 +344,3 @@ cah.$.DisconnectReason.BANNED = "B&"; cah.$.DisconnectReason.IDLE_TIMEOUT = "it"; cah.$.DisconnectReason.KICKED = "k"; cah.$.DisconnectReason.MANUAL = "man"; - diff --git a/pom.xml b/pom.xml index f1f20618..4d793e99 100644 --- a/pom.xml +++ b/pom.xml @@ -1,326 +1,324 @@ - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - net.socialgamer - pyx - 0.5.0-SNAPSHOT - jar + net.socialgamer + pyx + 0.5.0-SNAPSHOT + war - pyx + pyx - - https://github.com/ajanata/PretendYoureXyzzy - + + https://github.com/ajanata/PretendYoureXyzzy + - - UTF-8 - - - - - hibernatesqlite-maven - https://hibernate-sqlite.googlecode.com/svn/trunk/mavenrepo - - + + UTF-8 + 4.3.8.Final + 1.7.10 + 4.0-beta + - - - ajanata - Andy Janata - ajanata@gmail.com - - + + + hibernatesqlite-maven + https://hibernate-sqlite.googlecode.com/svn/trunk/mavenrepo + + + - - ROOT - - - org.codehaus.mojo - exec-maven-plugin - 1.1 - - - update-js-constants - package - - java - - - - - net.socialgamer.cah.UpdateJsConstants - - - - maven-compiler-plugin - 3.1 - - 1.7 - 1.7 - ${java.home}/bin + + + ajanata + Andy Janata + ajanata@gmail.com + + - - false - - - - org.apache.maven.plugins - maven-enforcer-plugin - 1.3.1 - - - enforce-files-exist - validate - - enforce - - - - - - build.properties - - - - true - - - - - - - org.codehaus.mojo - properties-maven-plugin - 1.0-alpha-2 - - - read-build-properties - initialize - - read-project-properties - - - - read-report-properties - pre-site - - read-project-properties - - - - - - build.properties - - - - - org.apache.maven.plugins - maven-war-plugin - 2.4 + + ROOT + + + org.codehaus.mojo + exec-maven-plugin + 1.1 + + + update-js-constants + package + + java + + + + + net.socialgamer.cah.UpdateJsConstants + + + + maven-compiler-plugin + 3.1 + + 1.8 + 1.8 + ${java.home}/bin - - + + false + + + + org.apache.maven.plugins + maven-enforcer-plugin + 1.3.1 + + + enforce-files-exist + validate + + enforce + + + + + + build.properties + + + + true + + + + + + + org.codehaus.mojo + properties-maven-plugin + 1.0-alpha-2 + + + read-build-properties + initialize + + read-project-properties + + + + read-report-properties + pre-site + + read-project-properties + + + + + + build.properties + + + + + org.apache.maven.plugins + maven-war-plugin + 2.4 - - - - src/main/resources - false - - - src/main/filtered-resources - true - - - WebContent - false - - + + - - false + + + + src/main/resources + false + + + src/main/filtered-resources + true + + + WebContent + false + + - - true - - - - org.eclipse.jetty - jetty-maven-plugin - 9.1.2.v20140210 + + false - - - - - - ${project.build.directory}/${project.build.artifact.name}/WEB-INF/web.xml - - - src/main/resources - - ${project.build.directory}/ROOT - - - - src/main/filtered-resources - - 0 - manual - WebContent - 8081 - STOP - - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - - org.codehaus.mojo - - - properties-maven-plugin - - - [1.0-alpha-2,) - - - - read-project-properties - - - - - - - - - - - - - - + + true + + + + org.eclipse.jetty + jetty-maven-plugin + 9.1.2.v20140210 - - - com.google.inject - guice - 3.0 - - - com.google.inject.extensions - guice-assistedinject - 3.0 - - - com.google.inject.extensions - guice-servlet - 3.0 - - - commons-collections - commons-collections - 3.1 - - - org.apache.commons - commons-lang3 - 3.1 - - - org.hibernate - hibernate-core - 3.6.10.Final - - - com.googlecode.json-simple - json-simple - 1.1 - - - javax.servlet - javax.servlet-api - 3.0.1 - - - org.xerial - sqlite-jdbc - 3.8.7 - - - org.slf4j - slf4j-log4j12 - 1.6.1 - runtime - - - org.slf4j - slf4j-api - 1.6.1 - compile - - - log4j - log4j - 1.2.17 - - - postgresql - postgresql - 8.4-702.jdbc3 - - - org.easymock - easymock - 3.1 - test - - - junit - junit - 4.11 - test - - - net.sourceforge.findbugs - jsr305 - 1.3.2 - compile - - - org.javassist - javassist - 3.19.0-GA - runtime - - + + + + + + ${project.build.directory}/${project.build.artifact.name}/WEB-INF/web.xml + + + + src/main/resources + + ${project.build.directory}/ROOT + + + + src/main/filtered-resources + + 0 + manual + WebContent + 8081 + STOP + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + org.codehaus.mojo + + + properties-maven-plugin + + + [1.0-alpha-2,) + + + + read-project-properties + + + + + + + + + + + + + + + + + + com.google.inject + guice + ${com.google.inject.version} + + + com.google.inject.extensions + guice-assistedinject + ${com.google.inject.version} + + + com.google.inject.extensions + guice-servlet + ${com.google.inject.version} + + + org.apache.commons + commons-collections4 + 4.0 + + + org.apache.commons + commons-lang3 + 3.3.2 + + + org.hibernate + hibernate-core + ${org.hibernate.version} + + + org.hibernate + hibernate-c3p0 + ${org.hibernate.version} + + + com.googlecode.json-simple + json-simple + 1.1.1 + + + javax.servlet + javax.servlet-api + 3.1.0 + + + org.xerial + sqlite-jdbc + 3.8.7 + + + org.slf4j + slf4j-log4j12 + ${org.slf4j.version} + runtime + + + org.slf4j + slf4j-api + ${org.slf4j.version} + compile + + + log4j + log4j + 1.2.17 + + + org.postgresql + postgresql + 9.4-1200-jdbc41 + + + org.easymock + easymock + 3.3.1 + test + + + junit + junit + 4.12 + test + + + com.google.code.findbugs + jsr305 + 3.0.0 + compile + + + org.javassist + javassist + 3.19.0-GA + runtime + + diff --git a/src/main/filtered-resources/WEB-INF/classes/hibernate.cfg.xml b/src/main/filtered-resources/WEB-INF/classes/hibernate.cfg.xml index 8929c62a..3f545202 100644 --- a/src/main/filtered-resources/WEB-INF/classes/hibernate.cfg.xml +++ b/src/main/filtered-resources/WEB-INF/classes/hibernate.cfg.xml @@ -1,25 +1,38 @@ + "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> - - ${hibernate.dialect} - ${hibernate.driver_class} - ${hibernate.url} - ${hibernate.username} - ${hibernate.password} - org.hibernate.transaction.JDBCTransactionFactory + + org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider + ${hibernate.dialect} + ${hibernate.driver_class} + ${hibernate.url} + ${hibernate.username} + ${hibernate.password} + org.hibernate.transaction.JDBCTransactionFactory + + + 3 + 25 + 3000 + 50 + 300 + 5 + 10000 + ${hibernate.cache.use_second_level_cache} ${hibernate.cache.provider_class} ${hibernate.cache.use_query_cache} - ${hibernate.sql.show} - ${hibernate.sql.format} - - - - - + ${hibernate.sql.show} + ${hibernate.sql.format} + + + + + + + diff --git a/src/main/java/net/socialgamer/cah/HibernateUtil.java b/src/main/java/net/socialgamer/cah/HibernateUtil.java index 23751569..0d38f467 100644 --- a/src/main/java/net/socialgamer/cah/HibernateUtil.java +++ b/src/main/java/net/socialgamer/cah/HibernateUtil.java @@ -1,16 +1,16 @@ /** * Copyright (c) 2012, Andy Janata * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without modification, are permitted * provided that the following conditions are met: - * + * * * Redistributions of source code must retain the above copyright notice, this list of conditions * and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, this list of * conditions and the following disclaimer in the documentation and/or other materials provided * with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR @@ -23,13 +23,16 @@ package net.socialgamer.cah; +import org.hibernate.HibernateException; import org.hibernate.SessionFactory; -import org.hibernate.cfg.AnnotationConfiguration; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.cfg.Configuration; +import org.hibernate.service.ServiceRegistry; /** * Utility class for Hibernate. - * + * * @author Andy Janata (ajanata@socialgamer.net) */ public class HibernateUtil { @@ -39,8 +42,19 @@ public class HibernateUtil { * Hibernate session factory to use. */ public final SessionFactory sessionFactory; + private static ServiceRegistry serviceRegistry; private HibernateUtil() { - sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory(); + final Configuration configuration = new Configuration(); + try { + configuration + .configure(); + } catch (final HibernateException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + serviceRegistry = new StandardServiceRegistryBuilder().applySettings( + configuration.getProperties()).build(); + sessionFactory = configuration.buildSessionFactory(serviceRegistry); } } diff --git a/src/main/java/net/socialgamer/cah/handlers/PlayCardHandler.java b/src/main/java/net/socialgamer/cah/handlers/PlayCardHandler.java index 969704f2..21cf6d50 100644 --- a/src/main/java/net/socialgamer/cah/handlers/PlayCardHandler.java +++ b/src/main/java/net/socialgamer/cah/handlers/PlayCardHandler.java @@ -1,16 +1,16 @@ /** * Copyright (c) 2012, Andy Janata * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without modification, are permitted * provided that the following conditions are met: - * + * * * Redistributions of source code must retain the above copyright notice, this list of conditions * and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, this list of * conditions and the following disclaimer in the documentation and/or other materials provided * with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR @@ -44,7 +44,7 @@ /** * Handler to play a card. - * + * * @author Andy Janata (ajanata@socialgamer.net) */ public class PlayCardHandler extends GameWithPlayerHandler { @@ -74,7 +74,7 @@ public Map handleWithUserInGame(final RequestWrapper req String text = request.getParameter(AjaxRequest.MESSAGE); if (text != null && text.contains("<")) { // somebody must be using a hacked client, because this should have been escaped already. - text = StringEscapeUtils.escapeXml(text); + text = StringEscapeUtils.escapeXml11(text); } final ErrorCode ec = game.playCard(user, cardId, text); diff --git a/src/main/java/net/socialgamer/cah/hibernate/SqliteDialect.java b/src/main/java/net/socialgamer/cah/hibernate/SqliteDialect.java index 0e7eb394..89d4fd88 100644 --- a/src/main/java/net/socialgamer/cah/hibernate/SqliteDialect.java +++ b/src/main/java/net/socialgamer/cah/hibernate/SqliteDialect.java @@ -13,11 +13,11 @@ import java.sql.Types; -import org.hibernate.Hibernate; import org.hibernate.dialect.Dialect; import org.hibernate.dialect.function.SQLFunctionTemplate; import org.hibernate.dialect.function.StandardSQLFunction; import org.hibernate.dialect.function.VarArgsSQLFunction; +import org.hibernate.type.StandardBasicTypes; public class SqliteDialect extends Dialect { @@ -47,10 +47,10 @@ public SqliteDialect() { registerColumnType(Types.CLOB, "clob"); registerColumnType(Types.BOOLEAN, "integer"); - registerFunction("concat", new VarArgsSQLFunction(Hibernate.STRING, "", "||", "")); - registerFunction("mod", new SQLFunctionTemplate(Hibernate.INTEGER, "?1 % ?2")); - registerFunction("substr", new StandardSQLFunction("substr", Hibernate.STRING)); - registerFunction("substring", new StandardSQLFunction("substr", Hibernate.STRING)); + registerFunction("concat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "", "||", "")); + registerFunction("mod", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "?1 % ?2")); + registerFunction("substr", new StandardSQLFunction("substr", StandardBasicTypes.STRING)); + registerFunction("substring", new StandardSQLFunction("substr", StandardBasicTypes.STRING)); } @Override diff --git a/src/main/java/net/socialgamer/cah/servlets/Schema.java b/src/main/java/net/socialgamer/cah/servlets/Schema.java index d83f387d..9fd1528e 100644 --- a/src/main/java/net/socialgamer/cah/servlets/Schema.java +++ b/src/main/java/net/socialgamer/cah/servlets/Schema.java @@ -1,16 +1,16 @@ /** * Copyright (c) 2012, Andy Janata * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without modification, are permitted * provided that the following conditions are met: - * + * * * Redistributions of source code must retain the above copyright notice, this list of conditions * and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, this list of * conditions and the following disclaimer in the documentation and/or other materials provided * with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR @@ -32,13 +32,13 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.hibernate.cfg.AnnotationConfiguration; -import org.hibernate.dialect.PostgreSQLDialect; +import org.hibernate.cfg.Configuration; +import org.hibernate.dialect.PostgreSQL82Dialect; /** * Servlet implementation class Schema. - * + * * Get the database schema for known Hibernate objects. */ @WebServlet("/Schema") @@ -51,9 +51,9 @@ public class Schema extends HttpServlet { @Override protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { - final AnnotationConfiguration c = new AnnotationConfiguration(); + final Configuration c = new Configuration(); c.configure(); - final String[] ls = c.generateSchemaCreationScript(new PostgreSQLDialect()); + final String[] ls = c.generateSchemaCreationScript(new PostgreSQL82Dialect()); final PrintWriter out = response.getWriter(); for (final String l : ls) { out.println(l + ";");