From: Simon Brandhof Date: Sun, 21 Oct 2012 19:28:30 +0000 (+0200) Subject: SONAR-3887 fix MySQL compatibility X-Git-Tag: 3.4~461 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0aaf2941ee812b63c7f84b357586ecfba9853b15;p=sonarqube.git SONAR-3887 fix MySQL compatibility --- diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreDao.java b/sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreDao.java index fd92ccc3a0f..288881f9fac 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreDao.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreDao.java @@ -71,7 +71,10 @@ public class SemaphoreDao { private void initialize(String name, SqlSession session, SemaphoreMapper mapper) { try { - mapper.initialize(name, org.sonar.api.utils.DateUtils.parseDate("2001-01-01")); + SemaphoreDto semaphore = new SemaphoreDto() + .setName(name) + .setLockedAt(org.sonar.api.utils.DateUtils.parseDate("2001-01-01")); + mapper.initialize(semaphore); session.commit(); } catch (Exception e) { diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreDto.java b/sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreDto.java new file mode 100644 index 00000000000..01f84aa3902 --- /dev/null +++ b/sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreDto.java @@ -0,0 +1,52 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2012 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * Sonar is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.core.persistence; + +import org.apache.commons.codec.digest.DigestUtils; + +import java.util.Date; + +/** + * @since 3.4 + */ +public class SemaphoreDto { + private String name; + private String checksum; + private Date lockedAt; + + public String getName() { + return name; + } + + public SemaphoreDto setName(String s) { + this.name = s; + this.checksum = DigestUtils.md5Hex(s); + return this; + } + + public Date getLockedAt() { + return lockedAt; + } + + public SemaphoreDto setLockedAt(Date d) { + this.lockedAt = d; + return this; + } +} diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreMapper.java b/sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreMapper.java index d77e8cd3c3f..4e862baa61a 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreMapper.java @@ -25,7 +25,7 @@ import java.util.Date; public interface SemaphoreMapper { - int initialize(@Param("name") String name, @Param("lockedAt") Date lockedAt); + int initialize(SemaphoreDto semaphore); int acquire(@Param("name") String name, @Param("lockedBefore") Date lockedBefore); diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/SemaphoreMapper.xml b/sonar-core/src/main/resources/org/sonar/core/persistence/SemaphoreMapper.xml index ea5f9f1102b..bd56b88be1c 100644 --- a/sonar-core/src/main/resources/org/sonar/core/persistence/SemaphoreMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/persistence/SemaphoreMapper.xml @@ -4,8 +4,8 @@ - INSERT INTO semaphores (name, created_at, updated_at, locked_at) - VALUES (#{name}, current_timestamp, current_timestamp, #{lockedAt}) + INSERT INTO semaphores (name, checksum, created_at, updated_at, locked_at) + VALUES (#{name}, #{checksum}, current_timestamp, current_timestamp, #{lockedAt})