aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-10-21 21:28:30 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2012-10-21 21:28:30 +0200
commit0aaf2941ee812b63c7f84b357586ecfba9853b15 (patch)
tree9f5b0027e4cb264072e6c21bf5b9820a878c10ac /sonar-core
parent602700de57516592e661e1a3b40fc15a180cd08e (diff)
downloadsonarqube-0aaf2941ee812b63c7f84b357586ecfba9853b15.tar.gz
sonarqube-0aaf2941ee812b63c7f84b357586ecfba9853b15.zip
SONAR-3887 fix MySQL compatibility
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreDao.java5
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreDto.java52
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreMapper.java2
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/persistence/SemaphoreMapper.xml4
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl3
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/persistence/SemaphoreDaoTest/old_semaphore.xml2
6 files changed, 62 insertions, 6 deletions
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 @@
<mapper namespace="org.sonar.core.persistence.SemaphoreMapper">
<insert id="initialize" parameterType="map" useGeneratedKeys="false">
- 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})
</insert>
<select id="now" resultType="Date">
diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
index 91b2f75a0eb..152c74226cb 100644
--- a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
+++ b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
@@ -508,6 +508,7 @@ CREATE TABLE "AUTHORS" (
CREATE TABLE "SEMAPHORES" (
"ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
"NAME" VARCHAR(4000),
+ "CHECKSUM" VARCHAR(200),
"CREATED_AT" TIMESTAMP,
"UPDATED_AT" TIMESTAMP,
"LOCKED_AT" TIMESTAMP
@@ -613,6 +614,6 @@ CREATE INDEX "INDEX_RULE_NOTES_ON_ACTIVE_RULE_ID" ON "RULE_NOTES" ("RULE_ID");
CREATE INDEX "REVIEWS_RID" ON "REVIEWS" ("RESOURCE_ID");
-CREATE UNIQUE INDEX "uniq_semaphore_names" ON "SEMAPHORES" ("NAME");
+CREATE UNIQUE INDEX "uniq_semaphore_names" ON "SEMAPHORES" ("CHECKSUM");
CREATE UNIQUE INDEX "uniq_author_logins" ON "AUTHORS" ("LOGIN");
diff --git a/sonar-core/src/test/resources/org/sonar/core/persistence/SemaphoreDaoTest/old_semaphore.xml b/sonar-core/src/test/resources/org/sonar/core/persistence/SemaphoreDaoTest/old_semaphore.xml
index 3d776e975c0..903ea7916c7 100644
--- a/sonar-core/src/test/resources/org/sonar/core/persistence/SemaphoreDaoTest/old_semaphore.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/persistence/SemaphoreDaoTest/old_semaphore.xml
@@ -1,3 +1,3 @@
<dataset>
- <semaphores id="1" name="foo" created_at="2010-01-25" updated_at="2010-01-25" locked_at="2010-01-25"/>
+ <semaphores id="1" name="foo" checksum="acbd18db4cc2f85cedef654fccc4a4d8" created_at="2010-01-25" updated_at="2010-01-25" locked_at="2010-01-25"/>
</dataset> \ No newline at end of file