コード例 #1
0
  public void rename(String oldName, String newName) throws SystemException {
    CounterRegister counterRegister = getCounterRegister(oldName);

    synchronized (counterRegister) {
      if (_counterRegisterMap.containsKey(newName)) {
        throw new SystemException("Cannot rename " + oldName + " to " + newName);
      }

      Connection connection = null;
      PreparedStatement preparedStatement = null;

      try {
        connection = getConnection();

        preparedStatement = connection.prepareStatement(_SQL_UPDATE_NAME_BY_NAME);

        preparedStatement.setString(1, newName);
        preparedStatement.setString(2, oldName);

        preparedStatement.executeUpdate();
      } catch (ObjectNotFoundException onfe) {
      } catch (Exception e) {
        throw processException(e);
      } finally {
        DataAccess.cleanUp(connection, preparedStatement);
      }

      counterRegister.setName(newName);

      _counterRegisterMap.put(newName, counterRegister);
      _counterRegisterMap.remove(oldName);
    }
  }