Skip to content

Commit 713ee9c

Browse files
author
Michael Wunderlich
committed
cleanup
1 parent b76a9d4 commit 713ee9c

File tree

6 files changed

+31
-61
lines changed

6 files changed

+31
-61
lines changed

.ebextensions/dev.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ option_settings:
44
aws:elasticbeanstalk:command:
55
DeploymentPolicy: AllAtOnce
66
IgnoreHealthCheck: "true"
7+
Timeout: 300
78
aws:elasticbeanstalk:monitoring:
89
Automatically Terminate Unhealthy Instances: "false"
910
aws:elasticbeanstalk:healthreporting:system:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ build/*
77
!.elasticbeanstalk/*.global.yml
88
*.zip
99
*.sh
10+
!bin/*.sh
1011
lib

public/app/userCollection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.service('UserCollection', function(UserService, api) {
66
return UserService.get({ id: userid })
77
}
88
var user = new UserService();
9-
if ( username == "random") {
9+
if ( username === "random") {
1010
return user.$save();
1111
} else {
1212
user.name = username;

src/main/java/scorekeep/MoveFactory.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package scorekeep;
2-
import java.util.*;
3-
import java.security.SecureRandom;
2+
43
import java.math.BigInteger;
5-
import java.lang.Exception;
4+
import java.security.SecureRandom;
5+
import java.util.HashMap;
6+
import java.util.List;
7+
import java.util.Set;
68

79
public class MoveFactory {
810
private SecureRandom random = new SecureRandom();
@@ -22,7 +24,7 @@ public Move newMove(String sessionId, String gameId, String userId, String moveT
2224
Move move = new Move(moveId, sessionId, gameId, userId, moveText);
2325
// load game state
2426
Game game = gameController.getGame(sessionId, gameId);
25-
ArrayList<String> states = game.getStates();
27+
List<String> states = game.getStates();
2628
State oldState = stateController.getState(sessionId, gameId, states.get(states.size() - 1));
2729
Set<String> oldTurn = oldState.getTurn();
2830
// check turn

src/main/java/scorekeep/MoveModel.java

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
11
package scorekeep;
22

3-
import java.io.File;
4-
import java.util.Iterator;
5-
import java.util.Map;
6-
import java.util.HashMap;
7-
import java.util.List;
8-
import java.util.Set;
9-
10-
import com.amazonaws.auth.AWSCredentials;
11-
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
12-
import com.amazonaws.auth.AWSCredentialsProvider;
3+
import com.amazonaws.regions.Regions;
134
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
145
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
156
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper;
167
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBQueryExpression;
178
import com.amazonaws.services.dynamodbv2.model.AttributeValue;
18-
import com.amazonaws.regions.Regions;
19-
import com.fasterxml.jackson.core.JsonFactory;
20-
import com.fasterxml.jackson.core.JsonParser;
21-
import com.fasterxml.jackson.databind.JsonNode;
22-
import com.fasterxml.jackson.databind.ObjectMapper;
23-
import com.fasterxml.jackson.databind.node.ObjectNode;
24-
import java.lang.Exception;
25-
import java.lang.Throwable;
9+
10+
import java.util.HashMap;
11+
import java.util.List;
12+
import java.util.Map;
2613

2714
public class MoveModel {
2815
/** AWS SDK credentials. */
@@ -37,17 +24,13 @@ public void saveMove(Move move) throws SessionNotFoundException, GameNotFoundExc
3724
// check session
3825
String sessionId = move.getSession();
3926
String gameId = move.getGame();
40-
try {
41-
if (sessionModel.loadSession(sessionId) == null ) {
42-
throw new SessionNotFoundException(sessionId);
43-
}
44-
if (gameModel.loadGame(gameId) == null ) {
45-
throw new GameNotFoundException(gameId);
46-
}
47-
mapper.save(move);
48-
} catch (Exception e) {
49-
throw e;
27+
if (sessionModel.loadSession(sessionId) == null ) {
28+
throw new SessionNotFoundException(sessionId);
29+
}
30+
if (gameModel.loadGame(gameId) == null ) {
31+
throw new GameNotFoundException(gameId);
5032
}
33+
mapper.save(move);
5134
}
5235

5336
public Move loadMove(String moveId) throws MoveNotFoundException {

src/main/java/scorekeep/StateModel.java

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
11
package scorekeep;
22

3-
import java.io.File;
4-
import java.util.Iterator;
5-
import java.util.Map;
6-
import java.util.HashMap;
7-
import java.util.List;
8-
import java.util.Set;
9-
10-
import com.amazonaws.auth.AWSCredentials;
11-
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
12-
import com.amazonaws.auth.AWSCredentialsProvider;
3+
import com.amazonaws.regions.Regions;
134
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
145
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
156
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper;
167
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBQueryExpression;
178
import com.amazonaws.services.dynamodbv2.model.AttributeValue;
18-
import com.amazonaws.regions.Regions;
19-
import com.fasterxml.jackson.core.JsonFactory;
20-
import com.fasterxml.jackson.core.JsonParser;
21-
import com.fasterxml.jackson.databind.JsonNode;
22-
import com.fasterxml.jackson.databind.ObjectMapper;
23-
import com.fasterxml.jackson.databind.node.ObjectNode;
24-
import java.lang.Exception;
25-
import java.lang.Throwable;
9+
10+
import java.util.HashMap;
11+
import java.util.List;
12+
import java.util.Map;
2613

2714
/** Saves state objects to DynamoDB
2815
Loads state objects from DynamoDB
@@ -41,17 +28,13 @@ public void saveState(State state) throws SessionNotFoundException, GameNotFound
4128
// check session
4229
String sessionId = state.getSession();
4330
String gameId = state.getGame();
44-
try {
45-
if (sessionModel.loadSession(sessionId) == null ) {
46-
throw new SessionNotFoundException(sessionId);
47-
}
48-
if (gameModel.loadGame(gameId) == null ) {
49-
throw new GameNotFoundException(gameId);
50-
}
51-
mapper.save(state);
52-
} catch (Exception e) {
53-
throw e;
31+
if (sessionModel.loadSession(sessionId) == null ) {
32+
throw new SessionNotFoundException(sessionId);
33+
}
34+
if (gameModel.loadGame(gameId) == null ) {
35+
throw new GameNotFoundException(gameId);
5436
}
37+
mapper.save(state);
5538
}
5639

5740
public State loadState(String stateId) throws StateNotFoundException {

0 commit comments

Comments
 (0)