Permalink
Browse files

version 1.0

  • Loading branch information...
juf
juf committed Jul 31, 2011
1 parent 7d0d6fd commit 636fef9c8fa627026c25090c22fcc1043cd28b01
Showing with 504 additions and 226 deletions.
  1. +8 −0 settings.xml
  2. +17 −0 src/main/java/JavaProject/.classpath
  3. +17 −0 src/main/java/JavaProject/.project
  4. +19 −19 src/main/java/JavaProject/src/ch/ethz/inf/vs/projectname/Handler.java
  5. +3 −0 src/main/java/JavaProject/src/ch/ethz/inf/vs/projectname/resources/BaseResource.java
  6. +19 −5 src/main/java/JavaProject/src/ch/ethz/inf/vs/projectname/resources/CurrentTurn.java
  7. +4 −4 src/main/java/JavaProject/src/ch/ethz/inf/vs/projectname/resources/Game.java
  8. +2 −2 src/main/java/JavaProject/src/ch/ethz/inf/vs/projectname/resources/Player.java
  9. +3 −3 src/main/java/JavaProject/src/ch/ethz/inf/vs/projectname/resources/Root.java
  10. +6 −6 src/main/java/JavaProject/src/ch/ethz/inf/vs/projectname/resources/Tournament.java
  11. +3 −3 src/main/java/JavaProject/src/ch/ethz/inf/vs/projectname/resources/Tournaments.java
  12. +4 −5 src/main/java/JavaProject/src/ch/ethz/inf/vs/projectname/resources/Turn.java
  13. +39 −22 src/main/scala/game/Game.scala
  14. +83 −54 src/main/scala/gameserver/GameServer.scala
  15. +5 −4 src/main/scala/messages/Messages.scala
  16. +70 −27 src/main/scala/messages/Replies.scala
  17. +2 −5 src/main/scala/player/Player.scala
  18. +66 −0 src/main/scala/resourceadministrator/ResourceAdministrator.scala
  19. +41 −22 src/main/scala/tournament/Tournament.scala
  20. +15 −4 src/main/scala/tournament/plan/DummyPlan.scala
  21. +11 −13 src/main/scala/tournament/plan/Plan.scala
  22. +5 −0 webresources/html/CurrentTurn.html
  23. +34 −2 webresources/html/Game.html
  24. +0 −8 webresources/html/Tournaments.html
  25. +9 −6 webresources/html/Turn.html
  26. +1 −1 webresources/html/Turns.html
  27. BIN webresources/images/32x32/possibleMove.png
  28. BIN webresources/images/small_logotype.jpg
  29. BIN webresources/images/step.gif
  30. BIN webresources/images/teaserbg.gif
  31. BIN webresources/images/teaserbg.jpg
  32. +18 −11 webresources/stylesheets/main.css
View
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+<entry key="maxGames">2</entry>
+<entry key="basePort">9999</entry>
+<entry key="reversiplans">tournament.plan.DummyPlan,tournament.plan.DummyPlan</entry>
+</properties>
+
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry excluding="ch/ethz/inf/vs/projectname/resources/" kind="src" path="src"/>
+ <classpathentry kind="src" path="src/ch/ethz/inf/vs/projectname/resources"/>
+ <classpathentry kind="lib" path="lib/jdom/jdom.jar"/>
+ <classpathentry kind="lib" path="lib/jersey/asm.jar"/>
+ <classpathentry kind="lib" path="lib/jersey/grizzly-servlet-webserver.jar"/>
+ <classpathentry kind="lib" path="lib/jersey/jersey-bundle.jar"/>
+ <classpathentry kind="lib" path="lib/jersey/jsr311.jar"/>
+ <classpathentry kind="lib" path="lib/json/json.jar"/>
+ <classpathentry kind="lib" path="lib/jython/jython.jar"/>
+ <classpathentry kind="lib" path="lib/restlet/org.restlet.ext.xml.jar"/>
+ <classpathentry kind="lib" path="lib/restlet/org.restlet.jar"/>
+ <classpathentry kind="lib" path="lib/restlet/org.simpleframework.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>JavaProject</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
@@ -22,10 +22,10 @@ private static ActorRef actorRefRequester(String actorName) {
return (ActorRef)o;
}
- public static RootReply getRoot(HashMap<String, Object> source) {
+ public static BaseReply getRoot(HashMap<String, Object> source) {
System.out.println("A GET was called on the dynamic resource \"" + source + "\"");
Object o = JerseyMain.REVERSI.sendRequestReply(new WebGetRoot());
- return ((RootReply)o);
+ return ((BaseReply)o);
}
public static List<String> loadTournament(HashMap<String, Object> source) {
@@ -35,12 +35,12 @@ public static RootReply getRoot(HashMap<String, Object> source) {
return (List<String>)o;
}
- public static TournamentsReply getTournaments(HashMap<String, Object> source) {
+ public static BaseReply getTournaments(HashMap<String, Object> source) {
System.out.println("A GET was called on the dynamic resource \"" + source + "\"");
Object o = JerseyMain.REVERSI.sendRequestReply(new WebGetTournaments());
- return (TournamentsReply)o;
+ return (BaseReply)o;
}
- //TODO
+ //Not used for now
public static void postTournaments(HashMap<String, Object> source, Object posterVar) {
System.out.println("A POST was called on the dynamic resource with data: \"" + posterVar + "\"");
@@ -62,7 +62,7 @@ public static void postTournaments(HashMap<String, Object> source, Object poster
return (List<String>)o;
}
- public static TournamentReply getTournament(HashMap<String, Object> source) {
+ public static BaseReply getTournament(HashMap<String, Object> source) {
System.out.println("A GET was called on the dynamic resource \"" + source + "\"");
String argument = source.get("tournament").toString();
@@ -71,7 +71,7 @@ public static TournamentReply getTournament(HashMap<String, Object> source) {
ActorRef actor = actorRefRequester("/tournaments/" + argument);
Object o = actor.sendRequestReply(new WebGetTournament());
- return (TournamentReply)o;
+ return (BaseReply)o;
}
public static void postTournament(HashMap<String, Object> source, Object posterVar) {
@@ -80,11 +80,10 @@ public static void postTournament(HashMap<String, Object> source, Object posterV
String argument = source.get("tournament").toString();
argument = argument.substring(1, argument.length()-1);
- JerseyMain.REVERSI.sendOneWay(new WebPostForTournament(argument, posterVar.toString()));
+ JerseyMain.REVERSI.sendRequestReply(new WebPostForTournament(argument, posterVar.toString())); //we don't care for the result
for(String key : source.keySet()) System.out.println("\t\" + key + \": " + source.get(key));
}
- //TODO
public static List<String> loadPlayer(HashMap<String, Object> source) {
System.out.println("A reflexive call has been executed on the dynamic resource \"" + source + "\"");
@@ -102,7 +101,7 @@ public static void postTournament(HashMap<String, Object> source, Object posterV
return (List<String>)o;
}
- public static String getGame(HashMap<String, Object> source) {
+ public static BaseReply getGame(HashMap<String, Object> source) {
System.out.println("A GET was called on the dynamic resource \"" + source + "\"");
String argument = source.get("tournament").toString();
@@ -114,10 +113,10 @@ public static String getGame(HashMap<String, Object> source) {
ActorRef actor = actorRefRequester("/tournaments/" + argument +"/"+ argument2);
Object o = actor.sendRequestReply(new WebGetGame());
- return (String)o;
+ return (BaseReply)o;
}
- public static PlayerReply getPlayer(HashMap<String, Object> source) {
+ public static BaseReply getPlayer(HashMap<String, Object> source) {
System.out.println("A GET was called on the dynamic resource \"" + source + "\"");
String argument = source.get("tournament").toString();
@@ -133,10 +132,10 @@ public static PlayerReply getPlayer(HashMap<String, Object> source) {
Object o = actor.sendRequestReply(new WebGetPlayer(argument3));
- return (PlayerReply)o;
+ return (BaseReply)o;
}
- public static CurrentTurnReply getCurrentTurn(HashMap<String, Object> source, String currentTurn) {
+ public static BaseReply getCurrentTurn(HashMap<String, Object> source, String currentTurn) {
System.out.println("A GET was called on the dynamic resource \"" + source + "\"");
String argument = source.get("tournament").toString();
@@ -147,7 +146,7 @@ public static CurrentTurnReply getCurrentTurn(HashMap<String, Object> source, St
ActorRef actor = actorRefRequester("/tournaments/" + argument +"/"+ argument2);
Object o = actor.sendRequestReply(new WebGetCurrentTurn(currentTurn));
- return (CurrentTurnReply)o;
+ return (BaseReply)o;
}
public static List<String> loadTurn(HashMap<String, Object> source) {
@@ -166,14 +165,15 @@ public static CurrentTurnReply getCurrentTurn(HashMap<String, Object> source, St
return (List<String>)o;
}
- //TODO
+
+ //GET is not need. Right now, we just need to load the collection.
public static String getTurns(HashMap<String, Object> source) {
System.out.println("A GET was called on the dynamic resource \"" + source + "\"");
return "Hello World!";
}
- //TODO
- public static TurnReply getTurn(HashMap<String, Object> source) {
+
+ public static BaseReply getTurn(HashMap<String, Object> source) {
System.out.println("A GET was called on the dynamic resource \"" + source + "\"");
String argument = source.get("tournament").toString();
@@ -189,7 +189,7 @@ public static TurnReply getTurn(HashMap<String, Object> source) {
Object o = actor.sendRequestReply(new WebGetTurn(argument3));
- return (TurnReply)o;
+ return (BaseReply)o;
}
@@ -160,6 +160,9 @@ protected String getRepresentationHTML() {
parentURI = parentURI.substring(0, parentURI.length() - 1);
representationBuildUp = representationBuildUp.replace("{{HomeUrl}}", "http://" + request.getServerName() + ":" + request.getServerPort());
+
+ representationBuildUp = representationBuildUp.replace("{{Domain}}", request.getServerName() );
+ representationBuildUp = representationBuildUp.replace("{{Path}}", resourceURI + "/");
if (parentName != null && !parentName.isEmpty()) {
representationBuildUp = representationBuildUp.replace("{{ParentUrl}}", parentURI);
@@ -50,7 +50,7 @@ public String handleGetHTML(@Context HttpServletRequest request, @Context UriInf
try {
turn = request.getCookies()[0].getValue();
} catch (java.lang.NullPointerException e) {
- turn = "turn0";
+ turn = "turnMinusOne";
}
asdfturn = turn;
System.out.println("the cookie containts: " + turn);
@@ -87,9 +87,16 @@ protected String getterListItem() {
@GET
@Produces("application/json")
public String handleGetJSON(@Context HttpServletRequest request, @Context UriInfo uri) {
-
+ String turn;
+ try {
+ turn = request.getCookies()[0].getValue();
+ } catch (java.lang.NullPointerException e) {
+ turn = "turnMinusOne";
+ }
+ asdfturn = turn;
+ System.out.println("the cookie containts: " + turn);
parseResourceInformation(request, uri);
-// getterValue = ch.ethz.inf.vs.projectname.Handler.getCurrentTurn(getSource()); // null
+ getterValue = ch.ethz.inf.vs.projectname.Handler.getCurrentTurn(getSource(),turn).renderJson(); // null
return getRepresentationJSON();
@@ -99,9 +106,16 @@ public String handleGetJSON(@Context HttpServletRequest request, @Context UriInf
@GET
@Produces("text/xml")
public String handleGetXML(@Context HttpServletRequest request, @Context UriInfo uri) {
-
+ String turn;
+ try {
+ turn = request.getCookies()[0].getValue();
+ } catch (java.lang.NullPointerException e) {
+ turn = "turn0";
+ }
+ asdfturn = turn;
+ System.out.println("the cookie containts: " + turn);
parseResourceInformation(request, uri);
- // getterValue = ch.ethz.inf.vs.projectname.Handler.getCurrentTurn(getSource()); // null
+ getterValue = ch.ethz.inf.vs.projectname.Handler.getCurrentTurn(getSource(),turn).renderXml(); // null
return getRepresentationXML();
@@ -37,7 +37,7 @@ public Game() {
@Override
public void handleGetters() {
- getterValue = ch.ethz.inf.vs.projectname.Handler.getGame(getSource()); // null
+// getterValue = ch.ethz.inf.vs.projectname.Handler.getGame(getSource()); // null
}
@@ -47,7 +47,7 @@ public void handleGetters() {
public String handleGetHTML(@Context HttpServletRequest request, @Context UriInfo uri) {
parseResourceInformation(request, uri);
- getterValue = ch.ethz.inf.vs.projectname.Handler.getGame(getSource()); // null
+ getterValue = ch.ethz.inf.vs.projectname.Handler.getGame(getSource()).renderHtml(); // null
return getRepresentationHTML();
@@ -59,7 +59,7 @@ public String handleGetHTML(@Context HttpServletRequest request, @Context UriInf
public String handleGetJSON(@Context HttpServletRequest request, @Context UriInfo uri) {
parseResourceInformation(request, uri);
- getterValue = ch.ethz.inf.vs.projectname.Handler.getGame(getSource()); // null
+ getterValue = ch.ethz.inf.vs.projectname.Handler.getGame(getSource()).renderJson(); // null
return getRepresentationJSON();
@@ -71,7 +71,7 @@ public String handleGetJSON(@Context HttpServletRequest request, @Context UriInf
public String handleGetXML(@Context HttpServletRequest request, @Context UriInfo uri) {
parseResourceInformation(request, uri);
- getterValue = ch.ethz.inf.vs.projectname.Handler.getGame(getSource()); // null
+ getterValue = ch.ethz.inf.vs.projectname.Handler.getGame(getSource()).renderXml(); // null
return getRepresentationXML();
@@ -59,7 +59,7 @@ public String handleGetHTML(@Context HttpServletRequest request, @Context UriInf
public String handleGetJSON(@Context HttpServletRequest request, @Context UriInfo uri) {
parseResourceInformation(request, uri);
-// getterValue = ch.ethz.inf.vs.projectname.Handler.getPlayer(getSource()); // null
+ getterValue = ch.ethz.inf.vs.projectname.Handler.getPlayer(getSource()).renderJson(); // null
return getRepresentationJSON();
@@ -71,7 +71,7 @@ public String handleGetJSON(@Context HttpServletRequest request, @Context UriInf
public String handleGetXML(@Context HttpServletRequest request, @Context UriInfo uri) {
parseResourceInformation(request, uri);
-// getterValue = ch.ethz.inf.vs.projectname.Handler.getPlayer(getSource()); // null
+ getterValue = ch.ethz.inf.vs.projectname.Handler.getPlayer(getSource()).renderXml(); // null
return getRepresentationXML();
@@ -37,7 +37,7 @@ public Root() {
@Override
public void handleGetters() {
- getterValue = ch.ethz.inf.vs.projectname.Handler.getRoot(getSource()).renderHtml(); // null
+// getterValue = ch.ethz.inf.vs.projectname.Handler.getRoot(getSource()).renderHtml(); // null
}
@@ -59,7 +59,7 @@ public String handleGetHTML(@Context HttpServletRequest request, @Context UriInf
public String handleGetJSON(@Context HttpServletRequest request, @Context UriInfo uri) {
parseResourceInformation(request, uri);
-// getterValue = ch.ethz.inf.vs.projectname.Handler.getRoot(getSource()); // null
+ getterValue = ch.ethz.inf.vs.projectname.Handler.getRoot(getSource()).renderJson(); // null
return getRepresentationJSON();
@@ -71,7 +71,7 @@ public String handleGetJSON(@Context HttpServletRequest request, @Context UriInf
public String handleGetXML(@Context HttpServletRequest request, @Context UriInfo uri) {
parseResourceInformation(request, uri);
-// getterValue = ch.ethz.inf.vs.projectname.Handler.getRoot(getSource()); // null
+ getterValue = ch.ethz.inf.vs.projectname.Handler.getRoot(getSource()).renderXml(); // null
return getRepresentationXML();
@@ -37,7 +37,7 @@ public Tournament() {
@Override
public void handleGetters() {
- getterValue = ch.ethz.inf.vs.projectname.Handler.getTournament(getSource()).renderHtml(); // null
+// getterValue = ch.ethz.inf.vs.projectname.Handler.getTournament(getSource()).renderHtml(); // null
}
@@ -59,7 +59,7 @@ public String handleGetHTML(@Context HttpServletRequest request, @Context UriInf
public String handleGetJSON(@Context HttpServletRequest request, @Context UriInfo uri) {
parseResourceInformation(request, uri);
-// getterValue = ch.ethz.inf.vs.projectname.Handler.getTournament(getSource()); // null
+ getterValue = ch.ethz.inf.vs.projectname.Handler.getTournament(getSource()).renderJson(); // null
return getRepresentationJSON();
@@ -71,7 +71,7 @@ public String handleGetJSON(@Context HttpServletRequest request, @Context UriInf
public String handleGetXML(@Context HttpServletRequest request, @Context UriInfo uri) {
parseResourceInformation(request, uri);
-// getterValue = ch.ethz.inf.vs.projectname.Handler.getTournament(getSource()); // null
+ getterValue = ch.ethz.inf.vs.projectname.Handler.getTournament(getSource()).renderXml(); // null
return getRepresentationXML();
@@ -84,7 +84,7 @@ public String handlePostHTML(@Context HttpServletRequest request, @Context UriIn
parseResourceInformation(request, uri);
// No Poster Description Given
ch.ethz.inf.vs.projectname.Handler.postTournament(getSource(), posterVar);
-
+ getterValue = ch.ethz.inf.vs.projectname.Handler.getTournament(getSource()).renderHtml();
return getRepresentationHTML();
}
@@ -116,7 +116,7 @@ public String handlePostJSON(@Context HttpServletRequest request, @Context UriIn
ResourceProtector.protect(request, authorizedHashesPost); parseResourceInformation(request, uri);
// No Poster Description Given
ch.ethz.inf.vs.projectname.Handler.postTournament(getSource(), posterVar);
-
+ getterValue = ch.ethz.inf.vs.projectname.Handler.getTournament(getSource()).renderJson();
return getRepresentationJSON();
}
@@ -126,7 +126,7 @@ public String handlePostXML(@Context HttpServletRequest request, @Context UriInf
ResourceProtector.protect(request, authorizedHashesPost); parseResourceInformation(request, uri);
// No Poster Description Given
ch.ethz.inf.vs.projectname.Handler.postTournament(getSource(), posterVar);
-
+ getterValue = ch.ethz.inf.vs.projectname.Handler.getTournament(getSource()).renderXml();
return getRepresentationXML();
}
@@ -37,7 +37,7 @@ public Tournaments() {
@Override
public void handleGetters() {
- getterValue = ch.ethz.inf.vs.projectname.Handler.getTournaments(getSource()).renderHtml(); // null
+// getterValue = ch.ethz.inf.vs.projectname.Handler.getTournaments(getSource()).renderHtml(); // null
}
@@ -59,7 +59,7 @@ public String handleGetHTML(@Context HttpServletRequest request, @Context UriInf
public String handleGetJSON(@Context HttpServletRequest request, @Context UriInfo uri) {
parseResourceInformation(request, uri);
-// getterValue = ch.ethz.inf.vs.projectname.Handler.getTournaments(getSource()); // null
+ getterValue = ch.ethz.inf.vs.projectname.Handler.getTournaments(getSource()).renderJson(); // null
return getRepresentationJSON();
@@ -71,7 +71,7 @@ public String handleGetJSON(@Context HttpServletRequest request, @Context UriInf
public String handleGetXML(@Context HttpServletRequest request, @Context UriInfo uri) {
parseResourceInformation(request, uri);
-// getterValue = ch.ethz.inf.vs.projectname.Handler.getTournaments(getSource()); // null
+ getterValue = ch.ethz.inf.vs.projectname.Handler.getTournaments(getSource()).renderXml(); // null
return getRepresentationXML();
Oops, something went wrong.

0 comments on commit 636fef9

Please sign in to comment.