Search in sources :

Example 6 with OrmDuplicateKeyException

use of com.google.gwtorm.server.OrmDuplicateKeyException in project gerrit by GerritCodeReview.

the class JdbcAccountPatchReviewStore method markReviewed.

@Override
public boolean markReviewed(PatchSet.Id psId, Account.Id accountId, String path) throws OrmException {
    try (Connection con = ds.getConnection();
        PreparedStatement stmt = con.prepareStatement("INSERT INTO account_patch_reviews " + "(account_id, change_id, patch_set_id, file_name) VALUES " + "(?, ?, ?, ?)")) {
        stmt.setInt(1, accountId.get());
        stmt.setInt(2, psId.getParentKey().get());
        stmt.setInt(3, psId.get());
        stmt.setString(4, path);
        stmt.executeUpdate();
        return true;
    } catch (SQLException e) {
        OrmException ormException = convertError("insert", e);
        if (ormException instanceof OrmDuplicateKeyException) {
            return false;
        }
        throw ormException;
    }
}
Also used : SQLException(java.sql.SQLException) OrmException(com.google.gwtorm.server.OrmException) OrmDuplicateKeyException(com.google.gwtorm.server.OrmDuplicateKeyException) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement)

Aggregations

OrmDuplicateKeyException (com.google.gwtorm.server.OrmDuplicateKeyException)6 OrmException (com.google.gwtorm.server.OrmException)3 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)2 Account (com.google.gerrit.reviewdb.client.Account)2 AccountGroup (com.google.gerrit.reviewdb.client.AccountGroup)2 ExternalId (com.google.gerrit.server.account.externalids.ExternalId)2 ExternalIdsUpdate (com.google.gerrit.server.account.externalids.ExternalIdsUpdate)2 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 SQLException (java.sql.SQLException)2 InvalidSshKeyException (com.google.gerrit.common.errors.InvalidSshKeyException)1 NameAlreadyUsedException (com.google.gerrit.common.errors.NameAlreadyUsedException)1 AccountInput (com.google.gerrit.extensions.api.accounts.AccountInput)1 AccountInfo (com.google.gerrit.extensions.common.AccountInfo)1 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)1 UnprocessableEntityException (com.google.gerrit.extensions.restapi.UnprocessableEntityException)1 AccountGroupMember (com.google.gerrit.reviewdb.client.AccountGroupMember)1 AccountGroupName (com.google.gerrit.reviewdb.client.AccountGroupName)1 Project (com.google.gerrit.reviewdb.client.Project)1 WatchConfig (com.google.gerrit.server.account.WatchConfig)1