diff --git a/src/java/com/threerings/parlor/rating/server/persist/RatingRepository.java b/src/java/com/threerings/parlor/rating/server/persist/RatingRepository.java index 2795035f..12f51572 100644 --- a/src/java/com/threerings/parlor/rating/server/persist/RatingRepository.java +++ b/src/java/com/threerings/parlor/rating/server/persist/RatingRepository.java @@ -32,7 +32,6 @@ import com.google.common.collect.Lists; import com.google.inject.Inject; import com.google.inject.Singleton; -import com.samskivert.io.PersistenceException; import com.samskivert.util.IntSet; import com.samskivert.jdbc.depot.DepotRepository; @@ -67,7 +66,6 @@ public class RatingRepository extends DepotRepository * {@link RatingRecord} object, or null if the player has no previous rating for the game. */ public RatingRecord getRating (int gameId, int playerId) - throws PersistenceException { return load(RatingRecord.class, RatingRecord.getKey(gameId, playerId)); } @@ -78,7 +76,6 @@ public class RatingRepository extends DepotRepository * and no greater than the number of given players. */ public List getRatings (int gameId, Integer... players) - throws PersistenceException { if (players.length == 0) { return Collections.emptyList(); @@ -97,7 +94,6 @@ public class RatingRepository extends DepotRepository * @param count the maximum number of ratings to return or -1 for all ratings. */ public List getRatings (int playerId, long since, int count) - throws PersistenceException { ArrayList clauses = new ArrayList(); if (since > 0L) { @@ -124,7 +120,6 @@ public class RatingRepository extends DepotRepository * @param playerIds an optional list of player ids to which to limit the top-rankings search. */ public List getTopRatings (int gameId, int limit, long since, IntSet playerIds) - throws PersistenceException { List where = Lists.newArrayList(); where.add(new Equals(RatingRecord.GAME_ID_C, gameId)); @@ -147,7 +142,6 @@ public class RatingRepository extends DepotRepository * or create a row. */ public void setRating (int gameId, int playerId, int rating, int experience) - throws PersistenceException { store(new RatingRecord(gameId, playerId, rating, experience)); } @@ -156,7 +150,6 @@ public class RatingRepository extends DepotRepository * Deletes the specified rating record. */ public void deleteRating (int gameId, int playerId) - throws PersistenceException { delete(RatingRecord.class, RatingRecord.getKey(gameId, playerId)); } @@ -166,7 +159,6 @@ public class RatingRepository extends DepotRepository * returned, rather a blank percentiler will be created and returned. */ public Percentiler loadPercentile (int gameId) - throws PersistenceException { PercentileRecord record = load(PercentileRecord.class, PercentileRecord.getKey(gameId)); return (record == null) ? new Percentiler() : new Percentiler(record.data); @@ -176,7 +168,6 @@ public class RatingRepository extends DepotRepository * Writes the supplied percentiler's data out to the database. */ public void updatePercentile (int gameId, Percentiler tiler) - throws PersistenceException { PercentileRecord record = new PercentileRecord(); record.gameId = gameId; diff --git a/src/java/com/threerings/stats/server/persist/StatRepository.java b/src/java/com/threerings/stats/server/persist/StatRepository.java index 77f13368..f5e96999 100644 --- a/src/java/com/threerings/stats/server/persist/StatRepository.java +++ b/src/java/com/threerings/stats/server/persist/StatRepository.java @@ -16,15 +16,15 @@ import com.google.inject.Inject; import com.google.inject.Singleton; import com.samskivert.io.ByteArrayOutInputStream; -import com.samskivert.io.PersistenceException; import com.samskivert.util.IntMap; import com.samskivert.util.IntMaps; -import com.samskivert.jdbc.DuplicateKeyException; import com.samskivert.jdbc.depot.CacheInvalidator; +import com.samskivert.jdbc.depot.DatabaseException; import com.samskivert.jdbc.depot.DepotRepository; -import com.samskivert.jdbc.depot.PersistenceContext.CacheEvictionFilter; +import com.samskivert.jdbc.depot.DuplicateKeyException; import com.samskivert.jdbc.depot.Key; +import com.samskivert.jdbc.depot.PersistenceContext.CacheEvictionFilter; import com.samskivert.jdbc.depot.PersistenceContext; import com.samskivert.jdbc.depot.PersistentRecord; import com.samskivert.jdbc.depot.clause.FieldDefinition; @@ -52,7 +52,6 @@ public class StatRepository extends DepotRepository * Constructs a new statistics repository with the specified persistence context. */ @Inject public StatRepository (PersistenceContext context) - throws PersistenceException { super(context); @@ -68,7 +67,6 @@ public class StatRepository extends DepotRepository * no effect on the stat's data. */ public T updateStat (int playerId, StatModifier modifier) - throws PersistenceException { Where where = new Where(StatRecord.PLAYER_ID_C, playerId, StatRecord.STAT_CODE_C, modifier.getType().code()); @@ -87,7 +85,7 @@ public class StatRepository extends DepotRepository } } - throw new PersistenceException( + throw new DatabaseException( "Unable to update stat after " + MAX_UPDATE_TRIES + " attempts " + "[stat=" + modifier.getType() + ", pid=" + playerId + "]"); } @@ -97,7 +95,6 @@ public class StatRepository extends DepotRepository * */ public ArrayList loadStats (int playerId) - throws PersistenceException { ArrayList stats = new ArrayList(); Where where = new Where(StatRecord.PLAYER_ID_C, playerId); @@ -114,7 +111,6 @@ public class StatRepository extends DepotRepository * Deletes all stats associated with the specified player. */ public void deleteStats (final int playerId) - throws PersistenceException { CacheInvalidator invalidator = new CacheInvalidator() { public void invalidate (PersistenceContext ctx) { @@ -159,7 +155,7 @@ public class StatRepository extends DepotRepository if (code == null) { try { code = assignStringCode(type, value); - } catch (PersistenceException pe) { + } catch (DatabaseException pe) { log.warning("Failed to assign code [type=" + type + ", value=" + value + "].", pe); // at this point the database is probably totally hosed, so we can just punt here, @@ -181,7 +177,7 @@ public class StatRepository extends DepotRepository // this mapping table from the database; then try again try { loadStringCodes(type); - } catch (PersistenceException pe) { + } catch (DatabaseException pe) { log.warning("Failed to reload string codes " + "[type=" + type + ", code=" + code + "].", pe); } @@ -252,13 +248,12 @@ public class StatRepository extends DepotRepository * simultaneously modified by another database client. */ protected boolean updateStat (int playerId, final Stat stat, boolean forceWrite) - throws PersistenceException { ByteArrayOutInputStream out = new ByteArrayOutInputStream(); try { stat.persistTo(new ObjectOutputStream(out), this); } catch (IOException ioe) { - throw new PersistenceException("Error serializing stat " + stat, ioe); + throw new DatabaseException("Error serializing stat " + stat, ioe); } byte[] data = out.toByteArray(); @@ -304,7 +299,6 @@ public class StatRepository extends DepotRepository /** Helper function for {@link #getStringCode}. */ protected Integer assignStringCode (final Stat.Type type, final String value) - throws PersistenceException { for (int ii = 0; ii < 10; ii++) { MaxStatCodeRecord maxRecord = load( @@ -325,7 +319,7 @@ public class StatRepository extends DepotRepository insert(new StringCodeRecord(type.code(), value, code)); return code; - } catch (PersistenceException pe) { + } catch (DatabaseException pe) { // if this is not a duplicate row exception, something is booched and we // just fail @@ -349,13 +343,12 @@ public class StatRepository extends DepotRepository ", value=" + value + "]."); } } - throw new PersistenceException( + throw new DatabaseException( "Unable to assign code after 10 attempts [type=" + type + ", value=" + value + "]"); } /** Helper function used at repository startup. */ protected void loadStringCodes (Stat.Type type) - throws PersistenceException { QueryClause[] clauses; if (type != null) {