summaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2015-02-17 10:01:05 +0100
committerStas Vilchik <vilchiks@gmail.com>2015-02-17 10:01:05 +0100
commitb49a6af322e4e59da24084a3aa8a008395057b7c (patch)
treef7e9ce7ced6226fc951736d1beaa86313e5563b6 /sonar-core
parent74008a8459940453f04fb63405532e03d6b87ecd (diff)
parent738f3ce3c9c13ac383f4c6c95342a20eb88d0dca (diff)
downloadsonarqube-b49a6af322e4e59da24084a3aa8a008395057b7c.tar.gz
sonarqube-b49a6af322e4e59da24084a3aa8a008395057b7c.zip
Merge branch 'master' into feature/branding
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/pom.xml24
-rw-r--r--sonar-core/src/main/java/org/sonar/batch/index/ResourceCopy.java3
-rw-r--r--sonar-core/src/main/java/org/sonar/core/component/ComponentDto.java4
-rw-r--r--sonar-core/src/main/java/org/sonar/core/component/db/ComponentIndexMapper.java30
-rw-r--r--sonar-core/src/main/java/org/sonar/core/component/db/ComponentMapper.java11
-rw-r--r--sonar-core/src/main/java/org/sonar/core/i18n/DurationLabel.java6
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/db/BatchIssueDto.java6
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/db/IssueChangeDao.java3
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/db/IssueDao.java7
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/db/IssueDto.java383
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/db/IssueMapper.java9
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java2
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java79
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreDao.java115
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreDto.java20
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreMapper.java8
-rw-r--r--sonar-core/src/main/java/org/sonar/core/plugins/PluginClassloaders.java2
-rw-r--r--sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java29
-rw-r--r--sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java7
-rw-r--r--sonar-core/src/main/java/org/sonar/core/purge/PurgeableSnapshotDto.java3
-rw-r--r--sonar-core/src/main/java/org/sonar/core/qualitygate/db/QualityGateConditionDto.java2
-rw-r--r--sonar-core/src/main/java/org/sonar/core/rule/CacheRuleFinder.java2
-rw-r--r--sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDao.java58
-rw-r--r--sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDto.java120
-rw-r--r--sonar-core/src/main/java/org/sonar/core/source/db/FileSourceMapper.java2
-rw-r--r--sonar-core/src/main/java/org/sonar/core/user/AuthorDao.java7
-rw-r--r--sonar-core/src/main/java/org/sonar/core/user/AuthorizationDao.java61
-rw-r--r--sonar-core/src/main/java/org/sonar/core/user/AuthorizationMapper.java38
-rw-r--r--sonar-core/src/main/java/org/sonar/core/user/UserDto.java41
-rw-r--r--sonar-core/src/main/java/org/sonar/core/user/UserMapper.java2
-rw-r--r--sonar-core/src/main/java/org/sonar/jpa/entity/ManualMeasure.java9
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/component/db/ComponentIndexMapper.xml16
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/component/db/ComponentMapper.xml24
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml104
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/persistence/SemaphoreMapper.xml16
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql14
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl22
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml4
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/source/db/FileSourceMapper.xml21
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/user/AuthorizationMapper.xml27
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/user/UserMapper.xml23
-rw-r--r--sonar-core/src/main/resources/org/sonar/l10n/core.properties1
-rw-r--r--sonar-core/src/test/java/org/sonar/core/component/ComponentDtoTest.java9
-rw-r--r--sonar-core/src/test/java/org/sonar/core/component/ComponentKeysTest.java2
-rw-r--r--sonar-core/src/test/java/org/sonar/core/component/ResourceComponentTest.java4
-rw-r--r--sonar-core/src/test/java/org/sonar/core/persistence/DaoUtilsTest.java43
-rw-r--r--sonar-core/src/test/java/org/sonar/core/persistence/SemaphoreDaoTest.java57
-rw-r--r--sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java2
-rw-r--r--sonar-core/src/test/java/org/sonar/core/source/db/FileSourceDaoTest.java87
-rw-r--r--sonar-core/src/test/java/org/sonar/core/user/AuthorizationDaoTest.java60
-rw-r--r--sonar-core/src/test/java/org/sonar/core/user/UserDtoTest.java45
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/issue/db/ActionPlanStatsDaoTest/should_find_by_project.xml18
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/issue/db/IssueChangeDaoTest/select_issue_changelog_by_module.xml30
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/issue/db/IssueChangeDaoTest/select_issue_changelog_by_module_are_sorted_by_creation_date.xml6
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/find_rules_by_component.xml18
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/find_severities_by_component.xml18
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_key.xml6
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_issue_and_component_ids.xml18
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_non_closed_issues_by_module.xml30
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_non_closed_issues_by_module_on_removed_project.xml24
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testInsert-result.xml6
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testUpdate-result.xml6
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStatsDaoTest/should_select_assignees.xml18
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_insert_new_issues-result.xml6
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_resolve_conflicts_on_updates-result.xml4
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_resolve_conflicts_on_updates.xml4
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_update_issues-result.xml6
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_update_issues.xml4
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/persistence/PreviewDatabaseFactoryTest/multi-modules-with-issues.xml12
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/persistence/PreviewDatabaseFactoryTest/should_create_database_with_issues.xml12
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/persistence/SemaphoreDaoTest/old_semaphore.xml4
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteResource.xml6
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/delete_file_sources_of_disabled_resources-result.xml2
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/delete_file_sources_of_disabled_resources.xml4
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/disable_resources_without_last_snapshot-result.xml16
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/disable_resources_without_last_snapshot.xml10
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/select_purgeable_file_uuids.xml4
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteProject.xml14
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/should_delete_all_closed_issues-result.xml16
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/should_delete_all_closed_issues.xml16
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/should_delete_old_closed_issues-result.xml16
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/should_delete_old_closed_issues.xml16
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/insert-result.xml21
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/shared.xml10
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/update-result.xml11
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/user/AuthorDaoTest/add_missing_module_uuid_path-result.xml4
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/user/AuthorizationDaoTest/user_should_be_authorized.xml3
87 files changed, 1220 insertions, 873 deletions
diff --git a/sonar-core/pom.xml b/sonar-core/pom.xml
index b1d6b8696e9..3682bc1fb64 100644
--- a/sonar-core/pom.xml
+++ b/sonar-core/pom.xml
@@ -53,6 +53,12 @@
</dependency>
<dependency>
<groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-batch-protocol</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-home</artifactId>
</dependency>
<dependency>
@@ -184,6 +190,24 @@
<build>
<plugins>
<plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>src/main/gen-java</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
diff --git a/sonar-core/src/main/java/org/sonar/batch/index/ResourceCopy.java b/sonar-core/src/main/java/org/sonar/batch/index/ResourceCopy.java
index 7364e115cf3..6a3ccd83029 100644
--- a/sonar-core/src/main/java/org/sonar/batch/index/ResourceCopy.java
+++ b/sonar-core/src/main/java/org/sonar/batch/index/ResourceCopy.java
@@ -19,6 +19,9 @@
*/
package org.sonar.batch.index;
+/**
+ * Used by views !!
+ */
public interface ResourceCopy {
int getCopyResourceId();
diff --git a/sonar-core/src/main/java/org/sonar/core/component/ComponentDto.java b/sonar-core/src/main/java/org/sonar/core/component/ComponentDto.java
index ca3a0b67a30..fe72cc88037 100644
--- a/sonar-core/src/main/java/org/sonar/core/component/ComponentDto.java
+++ b/sonar-core/src/main/java/org/sonar/core/component/ComponentDto.java
@@ -105,7 +105,7 @@ public class ComponentDto extends Dto<String> implements Component {
}
/**
- * Return the root project id. On a root project, return itself
+ * Return the root project uuid. On a root project, return itself
*/
public String projectUuid() {
return projectUuid;
@@ -235,7 +235,7 @@ public class ComponentDto extends Dto<String> implements Component {
}
public boolean isRootProject() {
- return MODULE_UUID_PATH_SEP.equals(moduleUuidPath) && Scopes.PROJECT.equals(scope);
+ return moduleUuid == null && Scopes.PROJECT.equals(scope);
}
@Override
diff --git a/sonar-core/src/main/java/org/sonar/core/component/db/ComponentIndexMapper.java b/sonar-core/src/main/java/org/sonar/core/component/db/ComponentIndexMapper.java
new file mode 100644
index 00000000000..694d0c752a6
--- /dev/null
+++ b/sonar-core/src/main/java/org/sonar/core/component/db/ComponentIndexMapper.java
@@ -0,0 +1,30 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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 this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.core.component.db;
+
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface ComponentIndexMapper {
+
+ List<Long> selectProjectIdsFromQueryAndViewOrSubViewUuid(@Param("query") String query, @Param("viewUuidQuery") String viewUuidQuery);
+}
diff --git a/sonar-core/src/main/java/org/sonar/core/component/db/ComponentMapper.java b/sonar-core/src/main/java/org/sonar/core/component/db/ComponentMapper.java
index 269ede5a461..1f057c62dc8 100644
--- a/sonar-core/src/main/java/org/sonar/core/component/db/ComponentMapper.java
+++ b/sonar-core/src/main/java/org/sonar/core/component/db/ComponentMapper.java
@@ -35,21 +35,12 @@ import java.util.List;
*/
public interface ComponentMapper {
- /**
- * Warning, projectId is always null
- */
@CheckForNull
ComponentDto selectByKey(String key);
- /**
- * Warning, projectId is always null
- */
@CheckForNull
ComponentDto selectById(long id);
- /**
- * Warning, projectId is always null
- */
@CheckForNull
ComponentDto selectByUuid(String uuid);
@@ -65,6 +56,8 @@ public interface ComponentMapper {
List<ComponentDto> findByKeys(@Param("keys") Collection<String> keys);
+ List<ComponentDto> findByIds(@Param("ids") Collection<Long> ids);
+
List<ComponentDto> findByUuids(@Param("uuids") Collection<String> uuids);
List<String> selectExistingUuids(@Param("uuids") Collection<String> uuids);
diff --git a/sonar-core/src/main/java/org/sonar/core/i18n/DurationLabel.java b/sonar-core/src/main/java/org/sonar/core/i18n/DurationLabel.java
index 2e3b9a0debd..4ec0d8db26d 100644
--- a/sonar-core/src/main/java/org/sonar/core/i18n/DurationLabel.java
+++ b/sonar-core/src/main/java/org/sonar/core/i18n/DurationLabel.java
@@ -52,15 +52,15 @@ class DurationLabel {
} else if (nbHours < 48) {
return message("day");
} else if (nbDays < 30) {
- return message("days", Double.valueOf(Math.floor(nbDays)).longValue());
+ return message("days", (long)(Math.floor(nbDays)));
} else if (nbDays < 60) {
return message( "month");
} else if (nbDays < 365) {
- return message("months", Double.valueOf(Math.floor(nbDays / 30)).longValue());
+ return message("months", (long)(Math.floor(nbDays / 30)));
} else if (nbYears < 2) {
return message("year");
}
- return message("years", Double.valueOf(Math.floor(nbYears)).longValue());
+ return message("years", (long)(Math.floor(nbYears)));
}
private static Result message(String key) {
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/BatchIssueDto.java b/sonar-core/src/main/java/org/sonar/core/issue/db/BatchIssueDto.java
index 4bdb30e5e82..c6c2e6012b9 100644
--- a/sonar-core/src/main/java/org/sonar/core/issue/db/BatchIssueDto.java
+++ b/sonar-core/src/main/java/org/sonar/core/issue/db/BatchIssueDto.java
@@ -36,7 +36,7 @@ public class BatchIssueDto {
private String componentKey;
private String ruleKey;
private String ruleRepo;
- private Date creationDate;
+ private Long creationTime;
public String getAssigneeLogin() {
return assigneeLogin;
@@ -147,11 +147,11 @@ public class BatchIssueDto {
}
public Date getCreationDate() {
- return creationDate;
+ return new Date(creationTime);
}
public BatchIssueDto setCreationDate(Date creationDate) {
- this.creationDate = creationDate;
+ this.creationTime = creationDate.getTime();
return this;
}
}
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueChangeDao.java b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueChangeDao.java
index b236a18b366..a766d024592 100644
--- a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueChangeDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueChangeDao.java
@@ -26,6 +26,7 @@ import org.sonar.api.BatchComponent;
import org.sonar.api.ServerComponent;
import org.sonar.api.issue.internal.DefaultIssueComment;
import org.sonar.api.issue.internal.FieldDiffs;
+import org.sonar.core.persistence.DaoComponent;
import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
@@ -43,7 +44,7 @@ import static com.google.common.collect.Maps.newHashMap;
/**
* @since 3.6
*/
-public class IssueChangeDao implements BatchComponent, ServerComponent {
+public class IssueChangeDao implements DaoComponent, BatchComponent, ServerComponent {
private final MyBatis mybatis;
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueDao.java b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueDao.java
index 7363ea8426f..240650e9d21 100644
--- a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueDao.java
@@ -30,10 +30,11 @@ import org.sonar.core.rule.RuleDto;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
-
import java.util.Date;
import java.util.List;
+import static org.sonar.api.utils.DateUtils.dateToLong;
+
/**
* @since 3.6
*/
@@ -67,12 +68,12 @@ public class IssueDao implements BatchComponent, ServerComponent {
// TODO replace by aggregation in IssueIndex
public List<RuleDto> findRulesByComponent(String componentKey, @Nullable Date createdAtOrAfter, DbSession session) {
- return mapper(session).findRulesByComponent(componentKey, createdAtOrAfter);
+ return mapper(session).findRulesByComponent(componentKey, dateToLong(createdAtOrAfter));
}
// TODO replace by aggregation in IssueIndex
public List<String> findSeveritiesByComponent(String componentKey, @Nullable Date createdAtOrAfter, DbSession session) {
- return mapper(session).findSeveritiesByComponent(componentKey, createdAtOrAfter);
+ return mapper(session).findSeveritiesByComponent(componentKey, dateToLong(createdAtOrAfter));
}
protected IssueMapper mapper(DbSession session) {
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueDto.java b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueDto.java
index d683a64cc11..9b726f4b4e3 100644
--- a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueDto.java
+++ b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueDto.java
@@ -37,10 +37,14 @@ import org.sonar.core.rule.RuleDto;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
+
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
+import static org.sonar.api.utils.DateUtils.dateToLong;
+import static org.sonar.api.utils.DateUtils.longToDate;
+
/**
* @since 3.6
*/
@@ -72,10 +76,10 @@ public final class IssueDto implements Serializable {
private long createdAt;
private long updatedAt;
- // functional dates
- private Date issueCreationDate;
- private Date issueUpdateDate;
- private Date issueCloseDate;
+ // functional dates stored as Long
+ private Long issueCreationDate;
+ private Long issueUpdateDate;
+ private Long issueCloseDate;
/**
* Temporary date used only during scan
@@ -93,6 +97,97 @@ public final class IssueDto implements Serializable {
private String filePath;
private String tags;
+ /**
+ * On batch side, component keys and uuid are useless
+ */
+ public static IssueDto toDtoForComputationInsert(DefaultIssue issue, int ruleId, long now) {
+ return new IssueDto()
+ .setKee(issue.key())
+ .setLine(issue.line())
+ .setMessage(issue.message())
+ .setEffortToFix(issue.effortToFix())
+ .setDebt(issue.debtInMinutes())
+ .setResolution(issue.resolution())
+ .setStatus(issue.status())
+ .setSeverity(issue.severity())
+ .setManualSeverity(issue.manualSeverity())
+ .setChecksum(issue.checksum())
+ .setReporter(issue.reporter())
+ .setAssignee(issue.assignee())
+ .setRuleId(ruleId)
+ .setRuleKey(issue.ruleKey().repository(), issue.ruleKey().rule())
+ .setTags(issue.tags())
+ .setComponentUuid(issue.componentUuid())
+ .setComponentKey(issue.componentKey())
+ .setModuleUuid(issue.moduleUuid())
+ .setModuleUuidPath(issue.moduleUuidPath())
+ .setComponentUuid(issue.componentUuid())
+ .setProjectUuid(issue.projectUuid())
+ .setProjectKey(issue.projectKey())
+ .setActionPlanKey(issue.actionPlanKey())
+ .setIssueAttributes(KeyValueFormat.format(issue.attributes()))
+ .setAuthorLogin(issue.authorLogin())
+ .setIssueCreationDate(issue.creationDate())
+ .setIssueCloseDate(issue.closeDate())
+ .setIssueUpdateDate(issue.updateDate())
+ .setSelectedAt(issue.selectedAt())
+
+ // technical dates
+ .setCreatedAt(now)
+ .setUpdatedAt(now);
+ }
+
+ /**
+ * On server side, we need component keys and uuid
+ */
+ public static IssueDto toDtoForServerInsert(DefaultIssue issue, ComponentDto component, ComponentDto project, int ruleId, long now) {
+ return toDtoForComputationInsert(issue, ruleId, now)
+ .setComponent(component)
+ .setProject(project);
+ }
+
+ public static IssueDto toDtoForUpdate(DefaultIssue issue, long now) {
+ // Invariant fields, like key and rule, can't be updated
+ return new IssueDto()
+ .setKee(issue.key())
+ .setLine(issue.line())
+ .setMessage(issue.message())
+ .setEffortToFix(issue.effortToFix())
+ .setDebt(issue.debtInMinutes())
+ .setResolution(issue.resolution())
+ .setStatus(issue.status())
+ .setSeverity(issue.severity())
+ .setChecksum(issue.checksum())
+ .setManualSeverity(issue.manualSeverity())
+ .setReporter(issue.reporter())
+ .setAssignee(issue.assignee())
+ .setActionPlanKey(issue.actionPlanKey())
+ .setIssueAttributes(KeyValueFormat.format(issue.attributes()))
+ .setAuthorLogin(issue.authorLogin())
+ .setRuleKey(issue.ruleKey().repository(), issue.ruleKey().rule())
+ .setTags(issue.tags())
+ .setComponentUuid(issue.componentUuid())
+ .setComponentKey(issue.componentKey())
+ .setModuleUuid(issue.moduleUuid())
+ .setModuleUuidPath(issue.moduleUuidPath())
+ .setProjectUuid(issue.projectUuid())
+ .setProjectKey(issue.projectKey())
+ .setIssueCreationDate(issue.creationDate())
+ .setIssueCloseDate(issue.closeDate())
+ .setIssueUpdateDate(issue.updateDate())
+ .setSelectedAt(issue.selectedAt())
+
+ // technical date
+ .setUpdatedAt(now);
+ }
+
+ public static IssueDto createFor(Project project, RuleDto rule) {
+ return new IssueDto()
+ .setProjectUuid(project.getUuid())
+ .setRuleId(rule.getId())
+ .setKee(Uuids.create());
+ }
+
public String getKey() {
return getKee();
}
@@ -134,15 +229,6 @@ public final class IssueDto implements Serializable {
return ruleId;
}
- public IssueDto setRule(RuleDto rule) {
- Preconditions.checkNotNull(rule.getId(), "Rule must be persisted.");
- this.ruleId = rule.getId();
- this.ruleKey = rule.getRuleKey();
- this.ruleRepo = rule.getRepositoryKey();
- this.language = rule.getLanguage();
- return this;
- }
-
/**
* please use setRule(RuleDto rule)
*/
@@ -288,129 +374,107 @@ public final class IssueDto implements Serializable {
return this;
}
+ /**
+ * Technical date
+ */
public long getCreatedAt() {
return createdAt;
}
- /**
- * Technical date
- */
public IssueDto setCreatedAt(long createdAt) {
this.createdAt = createdAt;
return this;
}
+ /**
+ * Technical date
+ */
public long getUpdatedAt() {
return updatedAt;
}
- /**
- * Technical date
- */
public IssueDto setUpdatedAt(long updatedAt) {
this.updatedAt = updatedAt;
return this;
}
- public Date getIssueCreationDate() {
+ public Long getIssueCreationTime() {
return issueCreationDate;
}
- public IssueDto setIssueCreationDate(@Nullable Date d) {
- this.issueCreationDate = d;
+ public IssueDto setIssueCreationTime(Long time) {
+ this.issueCreationDate = time;
return this;
}
- public Date getIssueUpdateDate() {
- return issueUpdateDate;
+ public Date getIssueCreationDate() {
+ return longToDate(issueCreationDate);
}
- public IssueDto setIssueUpdateDate(@Nullable Date d) {
- this.issueUpdateDate = d;
+ public IssueDto setIssueCreationDate(@Nullable Date d) {
+ this.issueCreationDate = dateToLong(d);
return this;
}
- public Date getIssueCloseDate() {
- return issueCloseDate;
+ public Long getIssueUpdateTime() {
+ return issueUpdateDate;
}
- public IssueDto setIssueCloseDate(@Nullable Date d) {
- this.issueCloseDate = d;
+ public IssueDto setIssueUpdateTime(Long time) {
+ this.issueUpdateDate = time;
return this;
}
- public String getRule() {
- return ruleKey;
- }
-
- public String getRuleRepo() {
- return ruleRepo;
- }
-
- public RuleKey getRuleKey() {
- return RuleKey.of(ruleRepo, ruleKey);
+ public Date getIssueUpdateDate() {
+ return longToDate(issueUpdateDate);
}
- public String getLanguage() {
- return language;
+ public IssueDto setIssueUpdateDate(@Nullable Date d) {
+ this.issueUpdateDate = dateToLong(d);
+ return this;
}
- public String getComponentKey() {
- return componentKey;
+ public Long getIssueCloseTime() {
+ return issueCloseDate;
}
- /**
- * Can be null on Views or Devs
- */
- @CheckForNull
- public String getComponentUuid() {
- return componentUuid;
+ public IssueDto setIssueCloseTime(Long time) {
+ this.issueCloseDate = time;
+ return this;
}
- @CheckForNull
- public String getModuleUuid() {
- return moduleUuid;
+ public Date getIssueCloseDate() {
+ return longToDate(issueCloseDate);
}
- @CheckForNull
- public String getModuleUuidPath() {
- return moduleUuidPath;
+ public IssueDto setIssueCloseDate(@Nullable Date d) {
+ this.issueCloseDate = dateToLong(d);
+ return this;
}
- /**
- * Used by the issue tracking mechanism, but it should used the component uuid instead
- */
- public String getProjectKey() {
- return projectKey;
+ public String getRule() {
+ return ruleKey;
}
- /**
- * Can be null on Views or Devs
- */
- @CheckForNull
- public String getProjectUuid() {
- return projectUuid;
+ public IssueDto setRule(RuleDto rule) {
+ Preconditions.checkNotNull(rule.getId(), "Rule must be persisted.");
+ this.ruleId = rule.getId();
+ this.ruleKey = rule.getRuleKey();
+ this.ruleRepo = rule.getRepositoryKey();
+ this.language = rule.getLanguage();
+ return this;
}
- @CheckForNull
- public Long getSelectedAt() {
- return selectedAt;
+ public String getRuleRepo() {
+ return ruleRepo;
}
- public IssueDto setSelectedAt(@Nullable Long d) {
- this.selectedAt = d;
- return this;
+ public RuleKey getRuleKey() {
+ return RuleKey.of(ruleRepo, ruleKey);
}
- /**
- * Should only be used to persist in E/S
- * <p/>
- * Please use {@link #setRule(org.sonar.core.rule.RuleDto)} instead
- */
- public IssueDto setRuleKey(String repo, String rule) {
- this.ruleRepo = repo;
- this.ruleKey = rule;
- return this;
+ public String getLanguage() {
+ return language;
}
/**
@@ -423,6 +487,10 @@ public final class IssueDto implements Serializable {
return this;
}
+ public String getComponentKey() {
+ return componentKey;
+ }
+
/**
* Should only be used to persist in E/S
* <p/>
@@ -434,6 +502,14 @@ public final class IssueDto implements Serializable {
}
/**
+ * Can be null on Views or Devs
+ */
+ @CheckForNull
+ public String getComponentUuid() {
+ return componentUuid;
+ }
+
+ /**
* Should only be used to persist in E/S
* <p/>
* Please use {@link #setComponent(org.sonar.core.component.ComponentDto)} instead
@@ -443,6 +519,11 @@ public final class IssueDto implements Serializable {
return this;
}
+ @CheckForNull
+ public String getModuleUuid() {
+ return moduleUuid;
+ }
+
/**
* Should only be used to persist in E/S
* <p/>
@@ -453,6 +534,11 @@ public final class IssueDto implements Serializable {
return this;
}
+ @CheckForNull
+ public String getModuleUuidPath() {
+ return moduleUuidPath;
+ }
+
/**
* Should only be used to persist in E/S
* <p/>
@@ -464,6 +550,13 @@ public final class IssueDto implements Serializable {
}
/**
+ * Used by the issue tracking mechanism, but it should used the component uuid instead
+ */
+ public String getProjectKey() {
+ return projectKey;
+ }
+
+ /**
* Should only be used to persist in E/S
* <p/>
* Please use {@link #setProject(org.sonar.core.component.ComponentDto)} instead
@@ -474,6 +567,14 @@ public final class IssueDto implements Serializable {
}
/**
+ * Can be null on Views or Devs
+ */
+ @CheckForNull
+ public String getProjectUuid() {
+ return projectUuid;
+ }
+
+ /**
* Should only be used to persist in E/S
* <p/>
* Please use {@link #setProject(org.sonar.core.component.ComponentDto)} instead
@@ -483,6 +584,27 @@ public final class IssueDto implements Serializable {
return this;
}
+ @CheckForNull
+ public Long getSelectedAt() {
+ return selectedAt;
+ }
+
+ public IssueDto setSelectedAt(@Nullable Long d) {
+ this.selectedAt = d;
+ return this;
+ }
+
+ /**
+ * Should only be used to persist in E/S
+ * <p/>
+ * Please use {@link #setRule(org.sonar.core.rule.RuleDto)} instead
+ */
+ public IssueDto setRuleKey(String repo, String rule) {
+ this.ruleRepo = repo;
+ this.ruleKey = rule;
+ return this;
+ }
+
/**
* Should only be used to persist in E/S
* <p/>
@@ -529,90 +651,6 @@ public final class IssueDto implements Serializable {
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
}
- /**
- * On batch side, component keys and uuid are useless
- */
- public static IssueDto toDtoForComputationInsert(DefaultIssue issue, int ruleId, long now) {
- return new IssueDto()
- .setKee(issue.key())
- .setLine(issue.line())
- .setMessage(issue.message())
- .setEffortToFix(issue.effortToFix())
- .setDebt(issue.debtInMinutes())
- .setResolution(issue.resolution())
- .setStatus(issue.status())
- .setSeverity(issue.severity())
- .setManualSeverity(issue.manualSeverity())
- .setChecksum(issue.checksum())
- .setReporter(issue.reporter())
- .setAssignee(issue.assignee())
- .setRuleId(ruleId)
- .setRuleKey(issue.ruleKey().repository(), issue.ruleKey().rule())
- .setTags(issue.tags())
- .setComponentUuid(issue.componentUuid())
- .setComponentKey(issue.componentKey())
- .setModuleUuid(issue.moduleUuid())
- .setModuleUuidPath(issue.moduleUuidPath())
- .setComponentUuid(issue.componentUuid())
- .setProjectUuid(issue.projectUuid())
- .setProjectKey(issue.projectKey())
- .setActionPlanKey(issue.actionPlanKey())
- .setIssueAttributes(KeyValueFormat.format(issue.attributes()))
- .setAuthorLogin(issue.authorLogin())
- .setIssueCreationDate(issue.creationDate())
- .setIssueCloseDate(issue.closeDate())
- .setIssueUpdateDate(issue.updateDate())
- .setSelectedAt(issue.selectedAt())
-
- // technical dates
- .setCreatedAt(now)
- .setUpdatedAt(now);
- }
-
- /**
- * On server side, we need component keys and uuid
- */
- public static IssueDto toDtoForServerInsert(DefaultIssue issue, ComponentDto component, ComponentDto project, int ruleId, long now) {
- return toDtoForComputationInsert(issue, ruleId, now)
- .setComponent(component)
- .setProject(project);
- }
-
- public static IssueDto toDtoForUpdate(DefaultIssue issue, long now) {
- // Invariant fields, like key and rule, can't be updated
- return new IssueDto()
- .setKee(issue.key())
- .setLine(issue.line())
- .setMessage(issue.message())
- .setEffortToFix(issue.effortToFix())
- .setDebt(issue.debtInMinutes())
- .setResolution(issue.resolution())
- .setStatus(issue.status())
- .setSeverity(issue.severity())
- .setChecksum(issue.checksum())
- .setManualSeverity(issue.manualSeverity())
- .setReporter(issue.reporter())
- .setAssignee(issue.assignee())
- .setActionPlanKey(issue.actionPlanKey())
- .setIssueAttributes(KeyValueFormat.format(issue.attributes()))
- .setAuthorLogin(issue.authorLogin())
- .setRuleKey(issue.ruleKey().repository(), issue.ruleKey().rule())
- .setTags(issue.tags())
- .setComponentUuid(issue.componentUuid())
- .setComponentKey(issue.componentKey())
- .setModuleUuid(issue.moduleUuid())
- .setModuleUuidPath(issue.moduleUuidPath())
- .setProjectUuid(issue.projectUuid())
- .setProjectKey(issue.projectKey())
- .setIssueCreationDate(issue.creationDate())
- .setIssueCloseDate(issue.closeDate())
- .setIssueUpdateDate(issue.updateDate())
- .setSelectedAt(issue.selectedAt())
-
- // technical date
- .setUpdatedAt(now);
- }
-
public DefaultIssue toDefaultIssue() {
DefaultIssue issue = new DefaultIssue();
issue.setKey(kee);
@@ -639,17 +677,10 @@ public final class IssueDto implements Serializable {
issue.setActionPlanKey(actionPlanKey);
issue.setAuthorLogin(authorLogin);
issue.setNew(false);
- issue.setCreationDate(issueCreationDate);
- issue.setCloseDate(issueCloseDate);
- issue.setUpdateDate(issueUpdateDate);
+ issue.setCreationDate(longToDate(issueCreationDate));
+ issue.setCloseDate(longToDate(issueCloseDate));
+ issue.setUpdateDate(longToDate(issueUpdateDate));
issue.setSelectedAt(selectedAt);
return issue;
}
-
- public static IssueDto createFor(Project project, RuleDto rule) {
- return new IssueDto()
- .setProjectUuid(project.getUuid())
- .setRuleId(rule.getId())
- .setKee(Uuids.create());
- }
}
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueMapper.java b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueMapper.java
index ac41ee8639e..59e6e4b10c3 100644
--- a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueMapper.java
+++ b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueMapper.java
@@ -23,21 +23,20 @@ import org.apache.ibatis.annotations.Param;
import org.sonar.core.rule.RuleDto;
import javax.annotation.Nullable;
-import java.util.Collection;
-import java.util.Date;
+
import java.util.List;
public interface IssueMapper {
IssueDto selectByKey(String key);
- List<IssueDto> selectByKeys(Collection<String> keys);
+ List<IssueDto> selectByKeys(List<String> keys);
List<IssueDto> selectByActionPlan(String actionPlan);
- List<RuleDto> findRulesByComponent(@Param("componentKey") String componentKey, @Nullable @Param("createdAt") Date createdAtOrAfter);
+ List<RuleDto> findRulesByComponent(@Param("componentKey") String componentKey, @Nullable @Param("createdAt") Long createdAtOrAfter);
- List<String> findSeveritiesByComponent(@Param("componentKey") String componentKey, @Nullable @Param("createdAt") Date createdAtOrAfter);
+ List<String> findSeveritiesByComponent(@Param("componentKey") String componentKey, @Nullable @Param("createdAt") Long createdAtOrAfter);
void insert(IssueDto issue);
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
index 6b07dd2255e..048e602afe9 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
@@ -33,7 +33,7 @@ import java.util.List;
*/
public class DatabaseVersion implements BatchComponent, ServerComponent {
- public static final int LAST_VERSION = 777;
+ public static final int LAST_VERSION = 790;
/**
* List of all the tables.n
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java
index 0390d6fabdf..2b5fa87277f 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java
@@ -25,11 +25,7 @@ import com.google.common.io.Closeables;
import org.apache.ibatis.builder.xml.XMLMapperBuilder;
import org.apache.ibatis.logging.LogFactory;
import org.apache.ibatis.mapping.Environment;
-import org.apache.ibatis.session.Configuration;
-import org.apache.ibatis.session.ExecutorType;
-import org.apache.ibatis.session.SqlSession;
-import org.apache.ibatis.session.SqlSessionFactory;
-import org.apache.ibatis.session.SqlSessionFactoryBuilder;
+import org.apache.ibatis.session.*;
import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory;
import org.apache.ibatis.type.JdbcType;
import org.slf4j.LoggerFactory;
@@ -43,19 +39,13 @@ import org.sonar.core.component.ComponentDto;
import org.sonar.core.component.FilePathWithHashDto;
import org.sonar.core.component.SnapshotDto;
import org.sonar.core.component.UuidWithProjectUuidDto;
+import org.sonar.core.component.db.ComponentIndexMapper;
import org.sonar.core.component.db.ComponentMapper;
import org.sonar.core.component.db.SnapshotMapper;
import org.sonar.core.computation.db.AnalysisReportDto;
import org.sonar.core.computation.db.AnalysisReportMapper;
import org.sonar.core.config.Logback;
-import org.sonar.core.dashboard.ActiveDashboardDto;
-import org.sonar.core.dashboard.ActiveDashboardMapper;
-import org.sonar.core.dashboard.DashboardDto;
-import org.sonar.core.dashboard.DashboardMapper;
-import org.sonar.core.dashboard.WidgetDto;
-import org.sonar.core.dashboard.WidgetMapper;
-import org.sonar.core.dashboard.WidgetPropertyDto;
-import org.sonar.core.dashboard.WidgetPropertyMapper;
+import org.sonar.core.dashboard.*;
import org.sonar.core.dependency.DependencyDto;
import org.sonar.core.dependency.DependencyMapper;
import org.sonar.core.dependency.ResourceSnapshotDto;
@@ -64,33 +54,11 @@ import org.sonar.core.duplication.DuplicationMapper;
import org.sonar.core.duplication.DuplicationUnitDto;
import org.sonar.core.graph.jdbc.GraphDto;
import org.sonar.core.graph.jdbc.GraphDtoMapper;
-import org.sonar.core.issue.db.ActionPlanDto;
-import org.sonar.core.issue.db.ActionPlanMapper;
-import org.sonar.core.issue.db.ActionPlanStatsDto;
-import org.sonar.core.issue.db.ActionPlanStatsMapper;
-import org.sonar.core.issue.db.BatchIssueDto;
-import org.sonar.core.issue.db.IssueChangeDto;
-import org.sonar.core.issue.db.IssueChangeMapper;
-import org.sonar.core.issue.db.IssueDto;
-import org.sonar.core.issue.db.IssueFilterDto;
-import org.sonar.core.issue.db.IssueFilterFavouriteDto;
-import org.sonar.core.issue.db.IssueFilterFavouriteMapper;
-import org.sonar.core.issue.db.IssueFilterMapper;
-import org.sonar.core.issue.db.IssueMapper;
-import org.sonar.core.measure.db.MeasureDto;
-import org.sonar.core.measure.db.MeasureFilterDto;
-import org.sonar.core.measure.db.MeasureFilterMapper;
-import org.sonar.core.measure.db.MeasureMapper;
-import org.sonar.core.measure.db.MetricDto;
-import org.sonar.core.measure.db.MetricMapper;
+import org.sonar.core.issue.db.*;
+import org.sonar.core.measure.db.*;
import org.sonar.core.notification.db.NotificationQueueDto;
import org.sonar.core.notification.db.NotificationQueueMapper;
-import org.sonar.core.permission.GroupWithPermissionDto;
-import org.sonar.core.permission.PermissionTemplateDto;
-import org.sonar.core.permission.PermissionTemplateGroupDto;
-import org.sonar.core.permission.PermissionTemplateMapper;
-import org.sonar.core.permission.PermissionTemplateUserDto;
-import org.sonar.core.permission.UserWithPermissionDto;
+import org.sonar.core.permission.*;
import org.sonar.core.persistence.dialect.Dialect;
import org.sonar.core.persistence.migration.v44.Migration44Mapper;
import org.sonar.core.persistence.migration.v45.Migration45Mapper;
@@ -100,22 +68,9 @@ import org.sonar.core.properties.PropertyDto;
import org.sonar.core.purge.IdUuidPair;
import org.sonar.core.purge.PurgeMapper;
import org.sonar.core.purge.PurgeableSnapshotDto;
-import org.sonar.core.qualitygate.db.ProjectQgateAssociationDto;
-import org.sonar.core.qualitygate.db.ProjectQgateAssociationMapper;
-import org.sonar.core.qualitygate.db.QualityGateConditionDto;
-import org.sonar.core.qualitygate.db.QualityGateConditionMapper;
-import org.sonar.core.qualitygate.db.QualityGateDto;
-import org.sonar.core.qualitygate.db.QualityGateMapper;
-import org.sonar.core.qualityprofile.db.ActiveRuleDto;
-import org.sonar.core.qualityprofile.db.ActiveRuleMapper;
-import org.sonar.core.qualityprofile.db.ActiveRuleParamDto;
-import org.sonar.core.qualityprofile.db.QualityProfileDto;
-import org.sonar.core.qualityprofile.db.QualityProfileMapper;
-import org.sonar.core.resource.ResourceDto;
-import org.sonar.core.resource.ResourceIndexDto;
-import org.sonar.core.resource.ResourceIndexerMapper;
-import org.sonar.core.resource.ResourceKeyUpdaterMapper;
-import org.sonar.core.resource.ResourceMapper;
+import org.sonar.core.qualitygate.db.*;
+import org.sonar.core.qualityprofile.db.*;
+import org.sonar.core.resource.*;
import org.sonar.core.rule.RuleDto;
import org.sonar.core.rule.RuleMapper;
import org.sonar.core.rule.RuleParamDto;
@@ -125,19 +80,7 @@ import org.sonar.core.technicaldebt.db.CharacteristicMapper;
import org.sonar.core.technicaldebt.db.RequirementMigrationDto;
import org.sonar.core.template.LoadedTemplateDto;
import org.sonar.core.template.LoadedTemplateMapper;
-import org.sonar.core.user.AuthorDto;
-import org.sonar.core.user.AuthorMapper;
-import org.sonar.core.user.GroupDto;
-import org.sonar.core.user.GroupMapper;
-import org.sonar.core.user.GroupMembershipDto;
-import org.sonar.core.user.GroupMembershipMapper;
-import org.sonar.core.user.GroupRoleDto;
-import org.sonar.core.user.RoleMapper;
-import org.sonar.core.user.UserDto;
-import org.sonar.core.user.UserGroupDto;
-import org.sonar.core.user.UserGroupMapper;
-import org.sonar.core.user.UserMapper;
-import org.sonar.core.user.UserRoleDto;
+import org.sonar.core.user.*;
import javax.annotation.Nullable;
@@ -262,7 +205,7 @@ public class MyBatis implements BatchComponent, ServerComponent {
GroupMembershipMapper.class, QualityProfileMapper.class, ActiveRuleMapper.class,
MeasureMapper.class, MetricMapper.class, QualityGateMapper.class, QualityGateConditionMapper.class, ComponentMapper.class, SnapshotMapper.class,
ProjectQgateAssociationMapper.class,
- AnalysisReportMapper.class,
+ AnalysisReportMapper.class, ComponentIndexMapper.class,
Migration45Mapper.class, Migration50Mapper.class
};
loadMappers(conf, mappers);
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 00fbcad5012..e50e39c3fa8 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
@@ -19,14 +19,15 @@
*/
package org.sonar.core.persistence;
-import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
-import org.apache.commons.lang.time.DateUtils;
import org.apache.ibatis.session.SqlSession;
import org.sonar.api.utils.Semaphores;
+import org.sonar.api.utils.System2;
import javax.annotation.CheckForNull;
-import java.util.Date;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static org.sonar.api.utils.DateUtils.longToDate;
/**
* @since 3.4
@@ -35,80 +36,66 @@ public class SemaphoreDao {
private static final String SEMAPHORE_NAME_MUST_NOT_BE_EMPTY = "Semaphore name must not be empty";
private final MyBatis mybatis;
+ private final System2 system;
- public SemaphoreDao(MyBatis mybatis) {
+ public SemaphoreDao(MyBatis mybatis, System2 system) {
this.mybatis = mybatis;
+ this.system = system;
}
public Semaphores.Semaphore acquire(String name, int maxAgeInSeconds) {
- Preconditions.checkArgument(!Strings.isNullOrEmpty(name), SEMAPHORE_NAME_MUST_NOT_BE_EMPTY);
- Preconditions.checkArgument(maxAgeInSeconds >= 0, "Semaphore max age must be positive: " + maxAgeInSeconds);
+ checkArgument(!Strings.isNullOrEmpty(name), SEMAPHORE_NAME_MUST_NOT_BE_EMPTY);
+ checkArgument(maxAgeInSeconds >= 0, "Semaphore max age must be positive: " + maxAgeInSeconds);
- SqlSession session = mybatis.openSession(false);
- try {
- SemaphoreMapper mapper = session.getMapper(SemaphoreMapper.class);
- Date dbNow = mapper.now();
- SemaphoreDto semaphore = tryToInsert(name, dbNow, session);
+ try (SqlSession session = mybatis.openSession(false)) {
+ SemaphoreDto semaphore = tryToInsert(name, system.now(), session);
boolean isAcquired;
if (semaphore == null) {
semaphore = selectSemaphore(name, session);
- isAcquired = acquireIfOutdated(name, maxAgeInSeconds, session, mapper);
+ isAcquired = acquireIfOutdated(name, maxAgeInSeconds, session);
} else {
isAcquired = true;
}
- return createLock(semaphore, session, isAcquired);
- } finally {
- MyBatis.closeQuietly(session);
+ return createLock(semaphore, isAcquired);
}
}
public Semaphores.Semaphore acquire(String name) {
- Preconditions.checkArgument(!Strings.isNullOrEmpty(name), SEMAPHORE_NAME_MUST_NOT_BE_EMPTY);
+ checkArgument(!Strings.isNullOrEmpty(name), SEMAPHORE_NAME_MUST_NOT_BE_EMPTY);
- SqlSession session = mybatis.openSession(false);
- try {
- SemaphoreMapper mapper = session.getMapper(SemaphoreMapper.class);
- Date now = mapper.now();
- SemaphoreDto semaphore = tryToInsert(name, now, session);
+ try (SqlSession session = mybatis.openSession(false)) {
+ SemaphoreDto semaphore = tryToInsert(name, system.now(), session);
if (semaphore == null) {
semaphore = selectSemaphore(name, session);
- return createLock(semaphore, session, false);
+ return createLock(semaphore, false);
} else {
- return createLock(semaphore, session, true);
+ return createLock(semaphore, true);
}
- } finally {
- MyBatis.closeQuietly(session);
}
}
public void update(Semaphores.Semaphore semaphore) {
- Preconditions.checkArgument(semaphore != null, "Semaphore must not be null");
+ checkArgument(semaphore != null, "Semaphore must not be null");
- SqlSession session = mybatis.openSession(false);
- try {
- SemaphoreMapper mapper = session.getMapper(SemaphoreMapper.class);
- mapper.update(semaphore.getName());
+ try (SqlSession session = mybatis.openSession(false)) {
+ mapper(session).update(semaphore.getName(), system.now());
session.commit();
- } finally {
- MyBatis.closeQuietly(session);
}
}
public void release(String name) {
- Preconditions.checkArgument(!Strings.isNullOrEmpty(name), SEMAPHORE_NAME_MUST_NOT_BE_EMPTY);
- SqlSession session = mybatis.openSession(false);
- try {
- session.getMapper(SemaphoreMapper.class).release(name);
+ checkArgument(!Strings.isNullOrEmpty(name), SEMAPHORE_NAME_MUST_NOT_BE_EMPTY);
+ try (SqlSession session = mybatis.openSession(false)) {
+ mapper(session).release(name);
session.commit();
- } finally {
- MyBatis.closeQuietly(session);
}
}
- private boolean acquireIfOutdated(String name, int maxAgeInSeconds, SqlSession session, SemaphoreMapper mapper) {
- Date dbNow = mapper.now();
- Date updatedBefore = DateUtils.addSeconds(dbNow, -maxAgeInSeconds);
- boolean ok = mapper.acquire(name, updatedBefore) == 1;
+ private boolean acquireIfOutdated(String name, int maxAgeInSeconds, SqlSession session) {
+ long now = system.now();
+ long updatedBefore = now - (long) maxAgeInSeconds * 1000;
+
+ boolean ok = mapper(session).acquire(name, updatedBefore, now) == 1;
session.commit();
return ok;
}
@@ -118,50 +105,46 @@ public class SemaphoreDao {
* the lock date)
*/
@CheckForNull
- private SemaphoreDto tryToInsert(String name, Date lockedNow, SqlSession session) {
+ private SemaphoreDto tryToInsert(String name, long lockedNow, SqlSession session) {
try {
- SemaphoreMapper mapper = session.getMapper(SemaphoreMapper.class);
+ long now = system.now();
SemaphoreDto semaphore = new SemaphoreDto()
- .setName(name)
- .setLockedAt(lockedNow);
- mapper.initialize(semaphore);
+ .setName(name)
+ .setCreatedAt(now)
+ .setUpdatedAt(now)
+ .setLockedAt(lockedNow);
+ mapper(session).initialize(semaphore);
session.commit();
return semaphore;
} catch (Exception e) {
- // probably because of the semaphore already exists in db
+ // probably because the semaphore already exists in db
session.rollback();
return null;
}
}
- private Semaphores.Semaphore createLock(SemaphoreDto dto, SqlSession session, boolean acquired) {
+ private Semaphores.Semaphore createLock(SemaphoreDto dto, boolean acquired) {
Semaphores.Semaphore semaphore = new Semaphores.Semaphore()
- .setName(dto.getName())
- .setLocked(acquired)
- .setLockedAt(dto.getLockedAt())
- .setCreatedAt(dto.getCreatedAt())
- .setUpdatedAt(dto.getUpdatedAt());
+ .setName(dto.getName())
+ .setLocked(acquired)
+ .setLockedAt(longToDate(dto.getLockedAt()))
+ .setCreatedAt(longToDate(dto.getCreatedAt()))
+ .setUpdatedAt(longToDate(dto.getUpdatedAt()));
if (!acquired) {
- semaphore.setDurationSinceLocked(getDurationSinceLocked(dto, session));
+ semaphore.setDurationSinceLocked(lockedSince(dto));
}
return semaphore;
}
- private long getDurationSinceLocked(SemaphoreDto semaphore, SqlSession session) {
- long now = now(session).getTime();
- semaphore.getLockedAt();
- long lockedAt = semaphore.getLockedAt().getTime();
- return now - lockedAt;
+ private long lockedSince(SemaphoreDto semaphore) {
+ return system.now() - semaphore.getLockedAt();
}
protected SemaphoreDto selectSemaphore(String name, SqlSession session) {
- SemaphoreMapper mapper = session.getMapper(SemaphoreMapper.class);
- return mapper.selectSemaphore(name);
+ return mapper(session).selectSemaphore(name);
}
- protected Date now(SqlSession session) {
- SemaphoreMapper mapper = session.getMapper(SemaphoreMapper.class);
- return mapper.now();
+ private SemaphoreMapper mapper(SqlSession session) {
+ return session.getMapper(SemaphoreMapper.class);
}
-
}
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
index b556030aa0a..d28bb804ab6 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreDto.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreDto.java
@@ -22,8 +22,6 @@ package org.sonar.core.persistence;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
-import java.util.Date;
-
/**
* @since 3.4
*/
@@ -31,9 +29,9 @@ public class SemaphoreDto {
private Long id;
private String name;
private String checksum;
- private Date lockedAt;
- private Date createdAt;
- private Date updatedAt;
+ private Long lockedAt;
+ private Long createdAt;
+ private Long updatedAt;
public String getName() {
return name;
@@ -45,11 +43,11 @@ public class SemaphoreDto {
return this;
}
- public Date getLockedAt() {
+ public Long getLockedAt() {
return lockedAt;
}
- public SemaphoreDto setLockedAt(Date d) {
+ public SemaphoreDto setLockedAt(Long d) {
this.lockedAt = d;
return this;
}
@@ -63,20 +61,20 @@ public class SemaphoreDto {
return this;
}
- public Date getCreatedAt() {
+ public Long getCreatedAt() {
return createdAt;
}
- public SemaphoreDto setCreatedAt(Date createdAt) {
+ public SemaphoreDto setCreatedAt(Long createdAt) {
this.createdAt = createdAt;
return this;
}
- public Date getUpdatedAt() {
+ public Long getUpdatedAt() {
return updatedAt;
}
- public SemaphoreDto setUpdatedAt(Date updatedAt) {
+ public SemaphoreDto setUpdatedAt(Long updatedAt) {
this.updatedAt = updatedAt;
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 489243cd931..22773833bbc 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
@@ -21,19 +21,15 @@ package org.sonar.core.persistence;
import org.apache.ibatis.annotations.Param;
-import java.util.Date;
-
public interface SemaphoreMapper {
int initialize(SemaphoreDto semaphore);
- int acquire(@Param("name") String name, @Param("updatedBefore") Date updatedBefore);
-
- Date now();
+ int acquire(@Param("name") String name, @Param("updatedBefore") Long updatedBefore, @Param("now") Long now);
void release(String name);
SemaphoreDto selectSemaphore(@Param("name") String name);
- void update(String name);
+ void update(@Param("name") String name, @Param("now") Long now);
}
diff --git a/sonar-core/src/main/java/org/sonar/core/plugins/PluginClassloaders.java b/sonar-core/src/main/java/org/sonar/core/plugins/PluginClassloaders.java
index 3565ee5639d..829af0cab7c 100644
--- a/sonar-core/src/main/java/org/sonar/core/plugins/PluginClassloaders.java
+++ b/sonar-core/src/main/java/org/sonar/core/plugins/PluginClassloaders.java
@@ -240,7 +240,7 @@ public class PluginClassloaders {
}
public void clean() {
- for (ClassRealm realm : (Collection<ClassRealm>) world.getRealms()) {
+ for (ClassRealm realm : world.getRealms()) {
try {
world.disposeRealm(realm.getId());
} catch (Exception e) {
diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java
index 65685305942..6af3a526fcd 100644
--- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java
@@ -32,10 +32,9 @@ import org.sonar.core.persistence.MyBatis;
import org.sonar.core.resource.ResourceDao;
import org.sonar.core.resource.ResourceDto;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
+
+import static org.sonar.api.utils.DateUtils.dateToLong;
/**
* @since 2.14
@@ -82,8 +81,8 @@ public class PurgeDao {
private void deleteOldClosedIssues(PurgeConfiguration conf, PurgeMapper mapper) {
Date toDate = conf.maxLiveDateOfClosedIssues();
- mapper.deleteOldClosedIssueChanges(conf.rootProjectIdUuid().getUuid(), toDate);
- mapper.deleteOldClosedIssues(conf.rootProjectIdUuid().getUuid(), toDate);
+ mapper.deleteOldClosedIssueChanges(conf.rootProjectIdUuid().getUuid(), dateToLong(toDate));
+ mapper.deleteOldClosedIssues(conf.rootProjectIdUuid().getUuid(), dateToLong(toDate));
}
private void deleteAbortedBuilds(ResourceDto project, PurgeCommands commands) {
@@ -91,7 +90,7 @@ public class PurgeDao {
LOG.info("<- Delete aborted builds");
PurgeSnapshotQuery query = PurgeSnapshotQuery.create()
.setIslast(false)
- .setStatus(new String[]{"U"})
+ .setStatus(new String[] {"U"})
.setRootProjectId(project.getId());
commands.deleteSnapshots(query);
}
@@ -100,7 +99,7 @@ public class PurgeDao {
private boolean hasAbortedBuilds(Long projectId, PurgeCommands commands) {
PurgeSnapshotQuery query = PurgeSnapshotQuery.create()
.setIslast(false)
- .setStatus(new String[]{"U"})
+ .setStatus(new String[] {"U"})
.setResourceId(projectId);
return !commands.selectSnapshotIds(query).isEmpty();
}
@@ -111,7 +110,7 @@ public class PurgeDao {
.setResourceId(project.getId())
.setIslast(false)
.setNotPurged(true)
- );
+ );
for (final Long projectSnapshotId : projectSnapshotIds) {
LOG.info("<- Clean snapshot " + projectSnapshotId);
if (!ArrayUtils.isEmpty(scopesWithoutHistoricalData)) {
@@ -131,16 +130,22 @@ public class PurgeDao {
}
private void disableOrphanResources(final ResourceDto project, final SqlSession session, final PurgeMapper purgeMapper, final PurgeListener purgeListener) {
+ final List<IdUuidPair> componentIdUuids = new ArrayList<IdUuidPair>();
session.select("org.sonar.core.purge.PurgeMapper.selectComponentIdUuidsToDisable", project.getId(), new ResultHandler() {
@Override
public void handleResult(ResultContext resultContext) {
IdUuidPair componentIdUuid = (IdUuidPair) resultContext.getResultObject();
if (componentIdUuid.getId() != null) {
- disableResource(componentIdUuid, purgeMapper);
- purgeListener.onComponentDisabling(componentIdUuid.getUuid());
+ componentIdUuids.add(componentIdUuid);
}
}
});
+
+ for (IdUuidPair componentIdUuid : componentIdUuids) {
+ disableResource(componentIdUuid, purgeMapper);
+ purgeListener.onComponentDisabling(componentIdUuid.getUuid());
+ }
+
session.commit();
}
@@ -195,7 +200,7 @@ public class PurgeDao {
mapper.setSnapshotIsLastToFalse(componentId);
mapper.deleteFileSourcesByUuid(componentIdUuid.getUuid());
mapper.disableResource(componentId);
- mapper.resolveResourceIssuesNotAlreadyResolved(componentIdUuid.getUuid(), new Date(system2.now()), system2.now());
+ mapper.resolveResourceIssuesNotAlreadyResolved(componentIdUuid.getUuid(), system2.now());
}
public PurgeDao deleteSnapshots(PurgeSnapshotQuery query) {
diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java
index c73cc86dd82..643cb15c4a9 100644
--- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java
+++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java
@@ -22,7 +22,6 @@ package org.sonar.core.purge;
import org.apache.ibatis.annotations.Param;
import javax.annotation.Nullable;
-import java.util.Date;
import java.util.List;
public interface PurgeMapper {
@@ -59,7 +58,7 @@ public interface PurgeMapper {
void disableResource(long resourceId);
- void resolveResourceIssuesNotAlreadyResolved(@Param("componentUuid") String componentUuid, @Param("date") Date date, @Param("dateAsLong") Long dateAsLong);
+ void resolveResourceIssuesNotAlreadyResolved(@Param("componentUuid") String componentUuid, @Param("dateAsLong") Long dateAsLong);
void deleteResourceIndex(@Param("resourceIds") List<Long> resourceIds);
@@ -95,9 +94,9 @@ public interface PurgeMapper {
void deleteComponentIssues(@Param("componentUuids") List<String> componentUuids);
- void deleteOldClosedIssueChanges(@Param("projectUuid") String projectUuid, @Nullable @Param("toDate") Date toDate);
+ void deleteOldClosedIssueChanges(@Param("projectUuid") String projectUuid, @Nullable @Param("toDate") Long toDate);
- void deleteOldClosedIssues(@Param("projectUuid") String projectUuid, @Nullable @Param("toDate") Date toDate);
+ void deleteOldClosedIssues(@Param("projectUuid") String projectUuid, @Nullable @Param("toDate") Long toDate);
void deleteFileSourcesByProjectUuid(String rootProjectUuid);
diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeableSnapshotDto.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeableSnapshotDto.java
index 23acb6fa52a..e3a8793bc90 100644
--- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeableSnapshotDto.java
+++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeableSnapshotDto.java
@@ -47,8 +47,7 @@ public class PurgeableSnapshotDto implements Comparable<PurgeableSnapshotDto> {
}
public PurgeableSnapshotDto setDate(Long aLong) {
- Date date = aLong == null ? null : new Date(aLong);
- this.date = date;
+ this.date = new Date(aLong);
return this;
}
diff --git a/sonar-core/src/main/java/org/sonar/core/qualitygate/db/QualityGateConditionDto.java b/sonar-core/src/main/java/org/sonar/core/qualitygate/db/QualityGateConditionDto.java
index 7fc5fc7a6e6..008822ec40f 100644
--- a/sonar-core/src/main/java/org/sonar/core/qualitygate/db/QualityGateConditionDto.java
+++ b/sonar-core/src/main/java/org/sonar/core/qualitygate/db/QualityGateConditionDto.java
@@ -86,7 +86,7 @@ public class QualityGateConditionDto {
private long metricId;
- private transient String metricKey;
+ private String metricKey;
private Integer period;
diff --git a/sonar-core/src/main/java/org/sonar/core/rule/CacheRuleFinder.java b/sonar-core/src/main/java/org/sonar/core/rule/CacheRuleFinder.java
index 96aab429ea5..564acb64baa 100644
--- a/sonar-core/src/main/java/org/sonar/core/rule/CacheRuleFinder.java
+++ b/sonar-core/src/main/java/org/sonar/core/rule/CacheRuleFinder.java
@@ -90,7 +90,7 @@ public final class CacheRuleFinder implements RuleFinder {
Hibernate.initialize(rule.getParams());
}
- protected final Rule doFindById(int ruleId) {
+ private Rule doFindById(int ruleId) {
DatabaseSession session = sessionFactory.getSession();
return session.getSingleResult(
session.createQuery("FROM " + Rule.class.getSimpleName() + " r WHERE r.id=:id and r.status<>:status")
diff --git a/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDao.java b/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDao.java
index c0a75f7a412..eced8499a4d 100644
--- a/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDao.java
@@ -31,6 +31,7 @@ import org.sonar.core.persistence.MyBatis;
import javax.annotation.CheckForNull;
+import java.io.InputStream;
import java.io.Reader;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -56,17 +57,48 @@ public class FileSourceDao implements BatchComponent, ServerComponent, DaoCompon
}
}
- public <T> void readDataStream(String fileUuid, Function<Reader, T> function) {
+ public <T> void readDataStream(String fileUuid, Function<InputStream, T> function) {
DbSession dbSession = mybatis.openSession(false);
+ Connection connection = dbSession.getConnection();
+ PreparedStatement pstmt = null;
+ ResultSet rs = null;
+ InputStream input = null;
try {
- readColumnStream(dbSession, fileUuid, function, "data");
+ pstmt = connection.prepareStatement("SELECT binary_data FROM file_sources WHERE file_uuid=?");
+ pstmt.setString(1, fileUuid);
+ rs = pstmt.executeQuery();
+ if (rs.next()) {
+ input = rs.getBinaryStream(1);
+ function.apply(input);
+ }
+ } catch (SQLException e) {
+ throw new IllegalStateException("Fail to read FILE_SOURCES.BINARY_DATA of file " + fileUuid, e);
} finally {
+ IOUtils.closeQuietly(input);
+ DbUtils.closeQuietly(connection, pstmt, rs);
MyBatis.closeQuietly(dbSession);
}
}
public <T> void readLineHashesStream(DbSession dbSession, String fileUuid, Function<Reader, T> function) {
- readColumnStream(dbSession, fileUuid, function, "line_hashes");
+ Connection connection = dbSession.getConnection();
+ PreparedStatement pstmt = null;
+ ResultSet rs = null;
+ Reader reader = null;
+ try {
+ pstmt = connection.prepareStatement("SELECT line_hashes FROM file_sources WHERE file_uuid=?");
+ pstmt.setString(1, fileUuid);
+ rs = pstmt.executeQuery();
+ if (rs.next()) {
+ reader = rs.getCharacterStream(1);
+ function.apply(reader);
+ }
+ } catch (SQLException e) {
+ throw new IllegalStateException("Fail to read FILE_SOURCES.LINE_HASHES of file " + fileUuid, e);
+ } finally {
+ IOUtils.closeQuietly(reader);
+ DbUtils.closeQuietly(connection, pstmt, rs);
+ }
}
public void insert(FileSourceDto dto) {
@@ -89,24 +121,4 @@ public class FileSourceDao implements BatchComponent, ServerComponent, DaoCompon
}
}
- private <T> void readColumnStream(DbSession dbSession, String fileUuid, Function<Reader, T> function, String column) {
- Connection connection = dbSession.getConnection();
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- Reader reader = null;
- try {
- pstmt = connection.prepareStatement("SELECT " + column + " FROM file_sources WHERE file_uuid = ?");
- pstmt.setString(1, fileUuid);
- rs = pstmt.executeQuery();
- if (rs.next()) {
- reader = rs.getCharacterStream(1);
- function.apply(reader);
- }
- } catch (SQLException e) {
- throw new IllegalStateException("Fail to read FILE_SOURCES." + column.toUpperCase() + " of file " + fileUuid, e);
- } finally {
- IOUtils.closeQuietly(reader);
- DbUtils.closeQuietly(connection, pstmt, rs);
- }
- }
}
diff --git a/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDto.java b/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDto.java
index 999ee5f2dd5..7840d213df6 100644
--- a/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDto.java
+++ b/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDto.java
@@ -19,36 +19,30 @@
*/
package org.sonar.core.source.db;
+import net.jpountz.lz4.LZ4BlockInputStream;
+import net.jpountz.lz4.LZ4BlockOutputStream;
+import org.apache.commons.io.IOUtils;
+import org.sonar.server.source.db.FileSourceDb;
+
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
-public class FileSourceDto {
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
- public static final int CSV_INDEX_SCM_REVISION = 0;
- public static final int CSV_INDEX_SCM_AUTHOR = 1;
- public static final int CSV_INDEX_SCM_DATE = 2;
- public static final int CSV_INDEX_UT_LINE_HITS = 3;
- public static final int CSV_INDEX_UT_CONDITIONS = 4;
- public static final int CSV_INDEX_UT_COVERED_CONDITIONS = 5;
- public static final int CSV_INDEX_IT_LINE_HITS = 6;
- public static final int CSV_INDEX_IT_CONDITIONS = 7;
- public static final int CSV_INDEX_IT_COVERED_CONDITIONS = 8;
- public static final int CSV_INDEX_OVERALL_LINE_HITS = 9;
- public static final int CSV_INDEX_OVERALL_CONDITIONS = 10;
- public static final int CSV_INDEX_OVERALL_COVERED_CONDITIONS = 11;
- public static final int CSV_INDEX_HIGHLIGHTING = 12;
- public static final int CSV_INDEX_SYMBOLS = 13;
- public static final int CSV_INDEX_DUPLICATIONS = 14;
+public class FileSourceDto {
private Long id;
private String projectUuid;
private String fileUuid;
private long createdAt;
private long updatedAt;
- private String data;
private String lineHashes;
- private String dataHash;
private String srcHash;
+ private byte[] binaryData;
+ private String dataHash;
public Long getId() {
return id;
@@ -77,32 +71,91 @@ public class FileSourceDto {
return this;
}
- @CheckForNull
- public String getData() {
- return data;
+ public String getDataHash() {
+ return dataHash;
}
- public FileSourceDto setData(@Nullable String data) {
- this.data = data;
+ /**
+ * MD5 of column BINARY_DATA. Used to know to detect data changes and need for update.
+ */
+ public FileSourceDto setDataHash(String s) {
+ this.dataHash = s;
return this;
}
- @CheckForNull
- public String getLineHashes() {
- return lineHashes;
+ /**
+ * Compressed value of serialized protobuf message {@link org.sonar.server.source.db.FileSourceDb.Data}
+ */
+ public byte[] getBinaryData() {
+ return binaryData;
}
- public FileSourceDto setLineHashes(@Nullable String lineHashes) {
- this.lineHashes = lineHashes;
+ /**
+ * Compressed value of serialized protobuf message {@link org.sonar.server.source.db.FileSourceDb.Data}
+ */
+ public FileSourceDb.Data getData() {
+ return decodeData(binaryData);
+ }
+
+ public static FileSourceDb.Data decodeData(byte[] binaryData) {
+ // stream is always closed
+ return decodeData(new ByteArrayInputStream(binaryData));
+ }
+
+ /**
+ * Decompress and deserialize content of column FILE_SOURCES.BINARY_DATA.
+ * The parameter "input" is always closed by this method.
+ */
+ public static FileSourceDb.Data decodeData(InputStream binaryInput) {
+ LZ4BlockInputStream lz4Input = null;
+ try {
+ lz4Input = new LZ4BlockInputStream(binaryInput);
+ return FileSourceDb.Data.parseFrom(lz4Input);
+ } catch (IOException e) {
+ throw new IllegalStateException("Fail to decompress and deserialize source data", e);
+ } finally {
+ IOUtils.closeQuietly(lz4Input);
+ }
+ }
+
+ /**
+ * Set compressed value of the protobuf message {@link org.sonar.server.source.db.FileSourceDb.Data}
+ */
+ public FileSourceDto setBinaryData(byte[] data) {
+ this.binaryData = data;
return this;
}
- public String getDataHash() {
- return dataHash;
+ public FileSourceDto setData(FileSourceDb.Data data) {
+ this.binaryData = encodeData(data);
+ return this;
+ }
+
+ /**
+ * Serialize and compress protobuf message {@link org.sonar.server.source.db.FileSourceDb.Data}
+ * in the column BINARY_DATA.
+ */
+ public static byte[] encodeData(FileSourceDb.Data data) {
+ ByteArrayOutputStream byteOutput = new ByteArrayOutputStream();
+ LZ4BlockOutputStream compressedOutput = new LZ4BlockOutputStream(byteOutput);
+ try {
+ data.writeTo(compressedOutput);
+ compressedOutput.close();
+ return byteOutput.toByteArray();
+ } catch (IOException e) {
+ throw new IllegalStateException("Fail to serialize and compress source data", e);
+ } finally {
+ IOUtils.closeQuietly(compressedOutput);
+ }
}
- public FileSourceDto setDataHash(String dataHash) {
- this.dataHash = dataHash;
+ @CheckForNull
+ public String getLineHashes() {
+ return lineHashes;
+ }
+
+ public FileSourceDto setLineHashes(@Nullable String lineHashes) {
+ this.lineHashes = lineHashes;
return this;
}
@@ -110,6 +163,9 @@ public class FileSourceDto {
return srcHash;
}
+ /**
+ * Hash of file content. Value is computed by batch.
+ */
public FileSourceDto setSrcHash(String srcHash) {
this.srcHash = srcHash;
return this;
diff --git a/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceMapper.java b/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceMapper.java
index 2fd054897eb..e8876892357 100644
--- a/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceMapper.java
+++ b/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceMapper.java
@@ -26,7 +26,7 @@ import java.util.List;
public interface FileSourceMapper {
- List<FileSourceDto> selectAllFileDataHashByProject(String projectUuid);
+ List<FileSourceDto> selectHashesForProject(String projectUuid);
@CheckForNull
FileSourceDto select(String fileUuid);
diff --git a/sonar-core/src/main/java/org/sonar/core/user/AuthorDao.java b/sonar-core/src/main/java/org/sonar/core/user/AuthorDao.java
index a5a9756c8ee..7b8d140d282 100644
--- a/sonar-core/src/main/java/org/sonar/core/user/AuthorDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/user/AuthorDao.java
@@ -19,14 +19,13 @@
*/
package org.sonar.core.user;
-import org.sonar.core.persistence.DaoComponent;
-
import com.google.common.base.Function;
import com.google.common.base.Strings;
import org.apache.ibatis.session.SqlSession;
import org.sonar.api.BatchComponent;
import org.sonar.api.ServerComponent;
import org.sonar.core.component.ComponentDto;
+import org.sonar.core.persistence.DaoComponent;
import org.sonar.core.persistence.DaoUtils;
import org.sonar.core.persistence.MyBatis;
import org.sonar.core.resource.ResourceDao;
@@ -84,9 +83,9 @@ public class AuthorDao implements BatchComponent, ServerComponent, DaoComponent
public void insertAuthorAndDeveloper(String login, ResourceDto resourceDto) {
SqlSession session = mybatis.openSession(false);
try {
- // Hack in order to set "." on DEV
+ // Hack in order to set the right module uuid path on DEVs
if (Strings.isNullOrEmpty(resourceDto.getModuleUuidPath())) {
- resourceDto.setModuleUuidPath(ComponentDto.MODULE_UUID_PATH_SEP);
+ resourceDto.setModuleUuidPath(ComponentDto.MODULE_UUID_PATH_SEP + resourceDto.getUuid() + ComponentDto.MODULE_UUID_PATH_SEP);
}
resourceDao.insertUsingExistingSession(resourceDto, session);
insertAuthor(login, resourceDto.getId(), session);
diff --git a/sonar-core/src/main/java/org/sonar/core/user/AuthorizationDao.java b/sonar-core/src/main/java/org/sonar/core/user/AuthorizationDao.java
index 530c9609f4d..31b778a4a5c 100644
--- a/sonar-core/src/main/java/org/sonar/core/user/AuthorizationDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/user/AuthorizationDao.java
@@ -19,14 +19,17 @@
*/
package org.sonar.core.user;
-import com.google.common.collect.ImmutableMap;
+import com.google.common.base.Function;
import com.google.common.collect.Sets;
import org.apache.ibatis.session.SqlSession;
import org.sonar.api.ServerComponent;
import org.sonar.core.persistence.DaoComponent;
+import org.sonar.core.persistence.DaoUtils;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
import javax.annotation.Nullable;
+
import java.util.*;
import static com.google.common.collect.Maps.newHashMap;
@@ -40,38 +43,48 @@ public class AuthorizationDao implements ServerComponent, DaoComponent {
this.mybatis = mybatis;
}
- public Set<String> keepAuthorizedComponentKeys(Set<String> componentKeys, @Nullable Integer userId, String role) {
- SqlSession session = mybatis.openSession(false);
- try {
- return keepAuthorizedComponentKeys(componentKeys, userId, role, session);
+ public Collection<Long> keepAuthorizedProjectIds(final DbSession session, final Collection<Long> componentIds, @Nullable final Integer userId, final String role) {
+ if (componentIds.isEmpty()) {
+ return Collections.emptySet();
+ }
+ return DaoUtils.executeLargeInputs(componentIds, new Function<List<Long>, List<Long>>() {
+ @Override
+ public List<Long> apply(List<Long> partition) {
+ if (userId == null) {
+ return session.getMapper(AuthorizationMapper.class).keepAuthorizedProjectIdsForAnonymous(role, componentIds);
+ } else {
+ return session.getMapper(AuthorizationMapper.class).keepAuthorizedProjectIdsForUser(userId, role, componentIds);
+ }
+ }
+ });
+ }
+ /**
+ * Used by the Views Plugin
+ */
+ public boolean isAuthorizedComponentKey(String componentKey, @Nullable Integer userId, String role) {
+ DbSession session = mybatis.openSession(false);
+ try {
+ return keepAuthorizedComponentKeys(session, Sets.newHashSet(componentKey), userId, role).size() == 1;
} finally {
MyBatis.closeQuietly(session);
}
}
- public Set<String> keepAuthorizedComponentKeys(Set<String> componentKeys, @Nullable Integer userId, String role, SqlSession session) {
+ private Set<String> keepAuthorizedComponentKeys(final DbSession session, final Set<String> componentKeys, @Nullable final Integer userId, final String role) {
if (componentKeys.isEmpty()) {
return Collections.emptySet();
}
- String sql;
- Map<String, Object> params;
- if (userId == null) {
- sql = "keepAuthorizedComponentKeysForAnonymous";
- params = ImmutableMap.of("role", role, "componentKeys", componentKeys);
- } else {
- sql = "keepAuthorizedComponentKeysForUser";
- params = ImmutableMap.of(USER_ID_PARAM, userId, "role", role, "componentKeys", componentKeys);
- }
-
- return Sets.newHashSet(session.<String>selectList(sql, params));
- }
-
- /**
- * Used by the Views Plugin
- */
- public boolean isAuthorizedComponentKey(String componentKey, @Nullable Integer userId, String role) {
- return keepAuthorizedComponentKeys(Sets.newHashSet(componentKey), userId, role).size() == 1;
+ return Sets.newHashSet(DaoUtils.executeLargeInputs(componentKeys, new Function<List<String>, List<String>>() {
+ @Override
+ public List<String> apply(List<String> partition) {
+ if (userId == null) {
+ return session.getMapper(AuthorizationMapper.class).keepAuthorizedComponentKeysForAnonymous(role, componentKeys);
+ } else {
+ return session.getMapper(AuthorizationMapper.class).keepAuthorizedComponentKeysForUser(userId, role, componentKeys);
+ }
+ }
+ }));
}
public Collection<String> selectAuthorizedRootProjectsKeys(@Nullable Integer userId, String role) {
diff --git a/sonar-core/src/main/java/org/sonar/core/user/AuthorizationMapper.java b/sonar-core/src/main/java/org/sonar/core/user/AuthorizationMapper.java
new file mode 100644
index 00000000000..10d137dffbd
--- /dev/null
+++ b/sonar-core/src/main/java/org/sonar/core/user/AuthorizationMapper.java
@@ -0,0 +1,38 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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 this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.core.user;
+
+import org.apache.ibatis.annotations.Param;
+
+import java.util.Collection;
+import java.util.List;
+
+public interface AuthorizationMapper {
+
+ List<Long> keepAuthorizedProjectIdsForAnonymous(@Param("role") String role, @Param("componentIds") Collection<Long> componentIds);
+
+ List<Long> keepAuthorizedProjectIdsForUser(@Param("userId") Integer userId, @Param("role") String role, @Param("componentIds") Collection<Long> componentIds);
+
+ List<String> keepAuthorizedComponentKeysForAnonymous(@Param("role") String role, @Param("componentKeys") Collection<String> componentKeys);
+
+ List<String> keepAuthorizedComponentKeysForUser(@Param("userId") Integer userId, @Param("role") String role, @Param("componentKeys") Collection<String> componentKeys);
+
+}
diff --git a/sonar-core/src/main/java/org/sonar/core/user/UserDto.java b/sonar-core/src/main/java/org/sonar/core/user/UserDto.java
index 3f62cf2fdbe..11cfc59cb08 100644
--- a/sonar-core/src/main/java/org/sonar/core/user/UserDto.java
+++ b/sonar-core/src/main/java/org/sonar/core/user/UserDto.java
@@ -19,13 +19,22 @@
*/
package org.sonar.core.user;
+import com.google.common.base.Splitter;
+import com.google.common.collect.Lists;
+import org.apache.commons.lang.StringUtils;
+
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* @since 3.2
*/
public class UserDto {
+ public static final char SCM_ACCOUNTS_SEPARATOR = '\n';
+
private Long id;
private String login;
private String name;
@@ -88,11 +97,39 @@ public class UserDto {
return scmAccounts;
}
- public UserDto setScmAccounts(@Nullable String scmAccounts) {
- this.scmAccounts = scmAccounts;
+ public List<String> getScmAccountsAsList() {
+ return decodeScmAccounts(scmAccounts);
+ }
+
+ /**
+ * List of SCM accounts separated by '|'
+ */
+ public UserDto setScmAccounts(@Nullable String s) {
+ this.scmAccounts = s;
return this;
}
+ public UserDto setScmAccounts(@Nullable List list) {
+ this.scmAccounts = encodeScmAccounts(list);
+ return this;
+ }
+
+ @CheckForNull
+ public static String encodeScmAccounts(@Nullable List<String> scmAccounts) {
+ if (scmAccounts != null && !scmAccounts.isEmpty()) {
+ return String.format("%s%s%s", SCM_ACCOUNTS_SEPARATOR, StringUtils.join(scmAccounts, SCM_ACCOUNTS_SEPARATOR), SCM_ACCOUNTS_SEPARATOR);
+ }
+ return null;
+ }
+
+ public static List<String> decodeScmAccounts(@Nullable String dbValue) {
+ if (dbValue == null) {
+ return new ArrayList<>();
+ } else {
+ return Lists.newArrayList(Splitter.on(SCM_ACCOUNTS_SEPARATOR).omitEmptyStrings().split(dbValue));
+ }
+ }
+
public String getCryptedPassword() {
return cryptedPassword;
}
diff --git a/sonar-core/src/main/java/org/sonar/core/user/UserMapper.java b/sonar-core/src/main/java/org/sonar/core/user/UserMapper.java
index 80c44052ea9..6658f10dc6a 100644
--- a/sonar-core/src/main/java/org/sonar/core/user/UserMapper.java
+++ b/sonar-core/src/main/java/org/sonar/core/user/UserMapper.java
@@ -36,7 +36,7 @@ public interface UserMapper {
* Can return multiple results if an email is used by many users (For instance, technical account can use the same email as a none technical account)
*/
@CheckForNull
- List<UserDto> selectNullableByScmAccountOrLoginOrEmail(String scmAccountOrLoginOrEmail);
+ List<UserDto> selectNullableByScmAccountOrLoginOrEmail(@Param("scmAccount") String scmAccountOrLoginOrEmail, @Param("likeScmAccount") String likeScmAccount);
@CheckForNull
UserDto selectUser(long userId);
diff --git a/sonar-core/src/main/java/org/sonar/jpa/entity/ManualMeasure.java b/sonar-core/src/main/java/org/sonar/jpa/entity/ManualMeasure.java
index b7e6b7201ff..4c12fb92ca8 100644
--- a/sonar-core/src/main/java/org/sonar/jpa/entity/ManualMeasure.java
+++ b/sonar-core/src/main/java/org/sonar/jpa/entity/ManualMeasure.java
@@ -23,7 +23,6 @@ import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import javax.persistence.*;
-import java.util.Date;
@Entity
@Table(name = "manual_measures")
@@ -51,10 +50,10 @@ public final class ManualMeasure {
private String description;
@Column(name = "created_at", updatable = true, nullable = true)
- private Date createdAt;
+ private Long createdAt;
@Column(name = "updated_at", updatable = true, nullable = true)
- private Date updatedAt;
+ private Long updatedAt;
@Column(name = "user_login", updatable = true, nullable = true, length = 40)
private String userLogin;
@@ -83,11 +82,11 @@ public final class ManualMeasure {
return resourceId;
}
- public Date getCreatedAt() {
+ public Long getCreatedAt() {
return createdAt;
}
- public Date getUpdatedAt() {
+ public Long getUpdatedAt() {
return updatedAt;
}
diff --git a/sonar-core/src/main/resources/org/sonar/core/component/db/ComponentIndexMapper.xml b/sonar-core/src/main/resources/org/sonar/core/component/db/ComponentIndexMapper.xml
new file mode 100644
index 00000000000..1e88b4100b9
--- /dev/null
+++ b/sonar-core/src/main/resources/org/sonar/core/component/db/ComponentIndexMapper.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.sonar.core.component.db.ComponentIndexMapper">
+
+ <select id="selectProjectIdsFromQueryAndViewOrSubViewUuid" parameterType="map" resultType="long">
+ SELECT r.resource_id FROM resource_index r
+ INNER JOIN projects copy ON copy.copy_resource_id = r.resource_id
+ <where>
+ AND copy.module_uuid_path LIKE #{viewUuidQuery}
+ AND r.kee LIKE #{query}
+ </where>
+ ORDER BY r.name_size
+ </select>
+
+</mapper>
+
diff --git a/sonar-core/src/main/resources/org/sonar/core/component/db/ComponentMapper.xml b/sonar-core/src/main/resources/org/sonar/core/component/db/ComponentMapper.xml
index 98426094cd2..e48052debb5 100644
--- a/sonar-core/src/main/resources/org/sonar/core/component/db/ComponentMapper.xml
+++ b/sonar-core/src/main/resources/org/sonar/core/component/db/ComponentMapper.xml
@@ -86,6 +86,19 @@
</where>
</select>
+ <select id="findByIds" parameterType="long" resultType="Component">
+ select
+ <include refid="componentColumns"/>
+ from projects p
+ <where>
+ p.enabled=${_true}
+ and p.id in
+ <foreach collection="ids" open="(" close=")" item="id" separator=",">
+ #{id}
+ </foreach>
+ </where>
+ </select>
+
<select id="findByUuids" parameterType="String" resultType="Component">
select <include refid="componentColumns"/>
from projects p
@@ -130,23 +143,22 @@
<sql id="modulesTreeQuery">
INNER JOIN projects root_project ON root_project.uuid = p.project_uuid AND root_project.enabled = ${_true}
- INNER JOIN projects module ON module.project_uuid = root_project.uuid AND module.enabled = ${_true} AND module.uuid = #{moduleUuid}
+ INNER JOIN projects module ON module.project_uuid = root_project.uuid AND module.enabled = ${_true} AND module.uuid = #{moduleUuid} AND module.scope='PRJ'
<where>
p.enabled = ${_true}
AND p.scope = #{scope}
- AND (p.uuid = module.uuid OR
+ AND
<choose>
<when test="_databaseId == 'mssql'">
- p.module_uuid_path LIKE module.module_uuid_path + module.uuid + '.%'
+ p.module_uuid_path LIKE module.module_uuid_path + '%'
</when>
<when test="_databaseId == 'mysql'">
- p.module_uuid_path LIKE concat(module.module_uuid_path, module.uuid, '.%')
+ p.module_uuid_path LIKE concat(module.module_uuid_path, '%')
</when>
<otherwise>
- p.module_uuid_path LIKE module.module_uuid_path || module.uuid || '.%'
+ p.module_uuid_path LIKE module.module_uuid_path || '%'
</otherwise>
</choose>
- )
</where>
</sql>
diff --git a/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml b/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml
index 8217084291c..a59f402fdec 100644
--- a/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml
+++ b/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml
@@ -23,9 +23,9 @@
i.author_login as authorLogin,
i.tags as tagsString,
i.issue_attributes as issueAttributes,
- i.issue_creation_date as issueCreationDate,
- i.issue_update_date as issueUpdateDate,
- i.issue_close_date as issueCloseDate,
+ i.issue_creation_date as issueCreationTime,
+ i.issue_update_date as issueUpdateTime,
+ i.issue_close_date as issueCloseTime,
i.created_at as createdAt,
i.updated_at as updatedAt,
r.plugin_rule_key as ruleKey,
@@ -53,13 +53,13 @@
i.assignee as assignee
</when>
<when test="'CREATION_DATE'.equals(query.sort())">
- i.issue_creation_date as issueCreationDate
+ i.issue_creation_date as issueCreationTime
</when>
<when test="'UPDATE_DATE'.equals(query.sort())">
- i.issue_update_date as issueUpdateDate
+ i.issue_update_date as issueUpdateTime
</when>
<when test="'CLOSE_DATE'.equals(query.sort())">
- i.issue_close_date as issueCloseDate
+ i.issue_close_date as issueCloseTime
</when>
</choose>
</if>
@@ -77,7 +77,7 @@
#{tagsString,jdbcType=VARCHAR}, #{resolution,jdbcType=VARCHAR}, #{checksum,jdbcType=VARCHAR},
#{reporter,jdbcType=VARCHAR}, #{assignee,jdbcType=VARCHAR}, #{authorLogin,jdbcType=VARCHAR},
#{issueAttributes,jdbcType=VARCHAR},
- #{issueCreationDate,jdbcType=TIMESTAMP},#{issueUpdateDate,jdbcType=TIMESTAMP}, #{issueCloseDate,jdbcType=TIMESTAMP},
+ #{issueCreationTime,jdbcType=BIGINT},#{issueUpdateTime,jdbcType=BIGINT}, #{issueCloseTime,jdbcType=BIGINT},
#{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT},
#{componentUuid,jdbcType=VARCHAR}, #{projectUuid,jdbcType=VARCHAR})
</insert>
@@ -87,26 +87,26 @@
-->
<update id="update" parameterType="Issue">
update issues set
- action_plan_key=#{actionPlanKey},
- severity=#{severity},
- manual_severity=#{manualSeverity},
- message=#{message},
- line=#{line},
- effort_to_fix=#{effortToFix},
- technical_debt=#{debt},
- status=#{status},
- resolution=#{resolution},
- checksum=#{checksum},
- reporter=#{reporter},
- assignee=#{assignee},
- author_login=#{authorLogin},
- tags=#{tagsString},
- project_uuid=#{projectUuid},
- issue_attributes=#{issueAttributes},
- issue_creation_date=#{issueCreationDate},
- issue_update_date=#{issueUpdateDate},
- issue_close_date=#{issueCloseDate},
- updated_at=#{updatedAt}
+ action_plan_key=#{actionPlanKey,jdbcType=VARCHAR},
+ severity=#{severity,jdbcType=VARCHAR},
+ manual_severity=#{manualSeverity,jdbcType=BOOLEAN},
+ message=#{message,jdbcType=VARCHAR},
+ line=#{line,jdbcType=INTEGER},
+ effort_to_fix=#{effortToFix,jdbcType=DOUBLE},
+ technical_debt=#{debt,jdbcType=INTEGER},
+ status=#{status,jdbcType=VARCHAR},
+ resolution=#{resolution,jdbcType=VARCHAR},
+ checksum=#{checksum,jdbcType=VARCHAR},
+ reporter=#{reporter,jdbcType=VARCHAR},
+ assignee=#{assignee,jdbcType=VARCHAR},
+ author_login=#{authorLogin,jdbcType=VARCHAR},
+ tags=#{tagsString,jdbcType=VARCHAR},
+ project_uuid=#{projectUuid,jdbcType=VARCHAR},
+ issue_attributes=#{issueAttributes,jdbcType=VARCHAR},
+ issue_creation_date=#{issueCreationTime,jdbcType=BIGINT},
+ issue_update_date=#{issueUpdateTime,jdbcType=BIGINT},
+ issue_close_date=#{issueCloseTime,jdbcType=BIGINT},
+ updated_at=#{updatedAt,jdbcType=BIGINT}
where kee = #{kee}
</update>
@@ -115,26 +115,26 @@
-->
<update id="updateIfBeforeSelectedDate" parameterType="Issue">
update issues set
- action_plan_key=#{actionPlanKey},
- severity=#{severity},
- manual_severity=#{manualSeverity},
- message=#{message},
- line=#{line},
- effort_to_fix=#{effortToFix},
- technical_debt=#{debt},
- status=#{status},
- resolution=#{resolution},
- checksum=#{checksum},
- reporter=#{reporter},
- assignee=#{assignee},
- author_login=#{authorLogin},
- tags=#{tagsString},
- project_uuid=#{projectUuid},
- issue_attributes=#{issueAttributes},
- issue_creation_date=#{issueCreationDate},
- issue_update_date=#{issueUpdateDate},
- issue_close_date=#{issueCloseDate},
- updated_at=#{updatedAt}
+ action_plan_key=#{actionPlanKey,jdbcType=VARCHAR},
+ severity=#{severity,jdbcType=VARCHAR},
+ manual_severity=#{manualSeverity,jdbcType=BOOLEAN},
+ message=#{message,jdbcType=VARCHAR},
+ line=#{line,jdbcType=INTEGER},
+ effort_to_fix=#{effortToFix,jdbcType=DOUBLE},
+ technical_debt=#{debt,jdbcType=INTEGER},
+ status=#{status,jdbcType=VARCHAR},
+ resolution=#{resolution,jdbcType=VARCHAR},
+ checksum=#{checksum,jdbcType=VARCHAR},
+ reporter=#{reporter,jdbcType=VARCHAR},
+ assignee=#{assignee,jdbcType=VARCHAR},
+ author_login=#{authorLogin,jdbcType=VARCHAR},
+ tags=#{tagsString,jdbcType=VARCHAR},
+ project_uuid=#{projectUuid,jdbcType=VARCHAR},
+ issue_attributes=#{issueAttributes,jdbcType=VARCHAR},
+ issue_creation_date=#{issueCreationTime,jdbcType=BIGINT},
+ issue_update_date=#{issueUpdateTime,jdbcType=BIGINT},
+ issue_close_date=#{issueCloseTime,jdbcType=BIGINT},
+ updated_at=#{updatedAt,jdbcType=BIGINT}
where kee = #{kee} and updated_at &lt;= #{selectedAt}
</update>
@@ -170,9 +170,9 @@
i.author_login as authorLogin,
i.tags as tagsString,
i.issue_attributes as issueAttributes,
- i.issue_creation_date as issueCreationDate,
- i.issue_update_date as issueUpdateDate,
- i.issue_close_date as issueCloseDate,
+ i.issue_creation_date as issueCreationTime,
+ i.issue_update_date as issueUpdateTime,
+ i.issue_close_date as issueCloseTime,
i.created_at as createdAt,
i.updated_at as updatedAt,
r.plugin_rule_key as ruleKey,
@@ -198,7 +198,7 @@
i.resolution as resolution,
i.checksum as checksum,
i.assignee as assigneeLogin,
- i.issue_creation_date as creationDate,
+ i.issue_creation_date as creationTime,
r.plugin_rule_key as ruleKey,
r.plugin_name as ruleRepo,
component.kee as componentKey
@@ -220,7 +220,7 @@
i.resolution as resolution,
i.checksum as checksum,
i.assignee as assigneeLogin,
- i.issue_creation_date as creationDate,
+ i.issue_creation_date as creationTime,
r.plugin_rule_key as ruleKey,
r.plugin_name as ruleRepo,
component.kee as componentKey
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 bdd0d86a85d..4c42b26ea17 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
@@ -5,20 +5,12 @@
<insert id="initialize" parameterType="map" useGeneratedKeys="false" >
INSERT INTO semaphores (name, checksum, created_at, updated_at, locked_at)
- VALUES (#{name}, #{checksum}, current_timestamp, current_timestamp, #{lockedAt})
+ VALUES (#{name}, #{checksum}, #{createdAt}, #{updatedAt}, #{lockedAt})
</insert>
- <select id="now" resultType="Date" >
- select current_timestamp
- </select>
-
- <select id="now" databaseId="oracle" resultType="Date" >
- select current_timestamp from dual
- </select>
-
<update id="acquire" parameterType="map">
update semaphores
- set updated_at = current_timestamp, locked_at = current_timestamp
+ set updated_at = #{now}, locked_at = #{now}
where name=#{name}
<if test="updatedBefore != null">
AND updated_at &lt; #{updatedBefore}
@@ -34,9 +26,9 @@
from semaphores s where s.name=#{name}
</select>
- <update id="update" parameterType="String" >
+ <update id="update" parameterType="map" >
update semaphores
- set updated_at = current_timestamp
+ set updated_at = #{now}
where name=#{name}
</update>
diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql
index 51201ffe081..af6b0b2df00 100644
--- a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql
+++ b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql
@@ -295,7 +295,6 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('763');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('764');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('765');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('766');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('767');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('768');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('769');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('770');
@@ -305,6 +304,19 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('773');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('775');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('776');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('777');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('778');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('779');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('780');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('781');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('782');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('783');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('784');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('785');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('786');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('787');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('788');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('789');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('790');
INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '1418215735482', '1418215735482', null, null);
ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
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 06133faa160..484d9265b83 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
@@ -227,7 +227,7 @@ CREATE TABLE "PROJECT_MEASURES" (
"RULES_CATEGORY_ID" INTEGER,
"TEXT_VALUE" VARCHAR(4000),
"TENDENCY" INTEGER,
- "MEASURE_DATE" TIMESTAMP,
+ "MEASURE_DATE" BIGINT,
"PROJECT_ID" INTEGER,
"ALERT_STATUS" VARCHAR(5),
"ALERT_TEXT" VARCHAR(4000),
@@ -275,8 +275,8 @@ CREATE TABLE "MANUAL_MEASURES" (
"TEXT_VALUE" VARCHAR(4000),
"USER_LOGIN" VARCHAR(255),
"DESCRIPTION" VARCHAR(4000),
- "CREATED_AT" TIMESTAMP,
- "UPDATED_AT" TIMESTAMP
+ "CREATED_AT" BIGINT,
+ "UPDATED_AT" BIGINT
);
CREATE TABLE "ACTIVE_RULES" (
@@ -291,7 +291,7 @@ CREATE TABLE "ACTIVE_RULES" (
CREATE TABLE "NOTIFICATIONS" (
"ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "DATA" BINARY(167772150)
+ "DATA" BLOB(167772150)
);
CREATE TABLE "USER_ROLES" (
@@ -403,9 +403,9 @@ 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
+ "CREATED_AT" BIGINT,
+ "UPDATED_AT" BIGINT,
+ "LOCKED_AT" BIGINT
);
CREATE TABLE "MEASURE_FILTERS" (
@@ -460,9 +460,9 @@ CREATE TABLE "ISSUES" (
"ACTION_PLAN_KEY" VARCHAR(50) NULL,
"ISSUE_ATTRIBUTES" VARCHAR(4000),
"TAGS" VARCHAR(4000),
- "ISSUE_CREATION_DATE" TIMESTAMP,
- "ISSUE_CLOSE_DATE" TIMESTAMP,
- "ISSUE_UPDATE_DATE" TIMESTAMP,
+ "ISSUE_CREATION_DATE" BIGINT,
+ "ISSUE_CLOSE_DATE" BIGINT,
+ "ISSUE_UPDATE_DATE" BIGINT,
"CREATED_AT" BIGINT,
"UPDATED_AT" BIGINT
);
@@ -554,8 +554,8 @@ CREATE TABLE "FILE_SOURCES" (
"ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
"PROJECT_UUID" VARCHAR(50) NOT NULL,
"FILE_UUID" VARCHAR(50) NOT NULL,
- "DATA" CLOB(2147483647),
"LINE_HASHES" CLOB(2147483647),
+ "BINARY_DATA" BLOB(167772150),
"DATA_HASH" VARCHAR(50) NOT NULL,
"SRC_HASH" VARCHAR(50) NULL,
"CREATED_AT" BIGINT NOT NULL,
diff --git a/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml b/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml
index 2bd8f7e9aae..38d83162163 100644
--- a/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml
+++ b/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml
@@ -177,8 +177,8 @@
</update>
<update id="resolveResourceIssuesNotAlreadyResolved" parameterType="map">
- UPDATE issues SET status='CLOSED',resolution='REMOVED',updated_at=#{dateAsLong},issue_close_date=#{date},
- issue_update_date=#{date}
+ UPDATE issues SET status='CLOSED',resolution='REMOVED',updated_at=#{dateAsLong},issue_close_date=#{dateAsLong},
+ issue_update_date=#{dateAsLong}
WHERE component_uuid=#{componentUuid} AND resolution IS NULL
</update>
diff --git a/sonar-core/src/main/resources/org/sonar/core/source/db/FileSourceMapper.xml b/sonar-core/src/main/resources/org/sonar/core/source/db/FileSourceMapper.xml
index 009f36d1451..2edae7f055c 100644
--- a/sonar-core/src/main/resources/org/sonar/core/source/db/FileSourceMapper.xml
+++ b/sonar-core/src/main/resources/org/sonar/core/source/db/FileSourceMapper.xml
@@ -5,29 +5,32 @@
<mapper namespace="org.sonar.core.source.db.FileSourceMapper">
<select id="select" parameterType="string" resultType="org.sonar.core.source.db.FileSourceDto">
- SELECT id, project_uuid as projectUuid, file_uuid as fileUuid, created_at as createdAt, updated_at as updatedAt, data, line_hashes as lineHashes, data_hash as dataHash, src_hash as srcHash
+ SELECT id, project_uuid as projectUuid, file_uuid as fileUuid, created_at as createdAt, updated_at as updatedAt,
+ binary_data as binaryData, line_hashes as lineHashes, data_hash as dataHash, src_hash as srcHash
FROM file_sources
WHERE file_uuid = #{fileUuid}
</select>
- <select id="selectAllFileDataHashByProject" parameterType="string" resultType="org.sonar.core.source.db.FileSourceDto">
+ <select id="selectHashesForProject" parameterType="string" resultType="org.sonar.core.source.db.FileSourceDto">
SELECT id, file_uuid as fileUuid, data_hash as dataHash, src_hash as srcHash
FROM file_sources
WHERE project_uuid = #{projectUuid}
</select>
<insert id="insert" parameterType="org.sonar.core.source.db.FileSourceDto" useGeneratedKeys="false">
- insert into file_sources (project_uuid, file_uuid, created_at, updated_at, data, line_hashes, data_hash, src_hash)
- values (#{projectUuid,jdbcType=VARCHAR}, #{fileUuid,jdbcType=VARCHAR}, #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT}, #{data,jdbcType=CLOB}, #{lineHashes,jdbcType=CLOB}, #{dataHash,jdbcType=VARCHAR}, #{srcHash,jdbcType=VARCHAR})
+ insert into file_sources (project_uuid, file_uuid, created_at, updated_at, binary_data, line_hashes, data_hash, src_hash)
+ values (#{projectUuid,jdbcType=VARCHAR}, #{fileUuid,jdbcType=VARCHAR}, #{createdAt,jdbcType=BIGINT},
+ #{updatedAt,jdbcType=BIGINT}, #{binaryData,jdbcType=BLOB}, #{lineHashes,jdbcType=CLOB},
+ #{dataHash,jdbcType=VARCHAR}, #{srcHash,jdbcType=VARCHAR})
</insert>
<update id="update" parameterType="org.sonar.core.source.db.FileSourceDto" useGeneratedKeys="false">
update file_sources set
- updated_at = #{updatedAt},
- data = #{data},
- line_hashes = #{lineHashes},
- data_hash = #{dataHash},
- src_hash = #{srcHash}
+ updated_at = #{updatedAt,jdbcType=BIGINT},
+ binary_data = #{binaryData,jdbcType=BLOB},
+ line_hashes = #{lineHashes,jdbcType=CLOB},
+ data_hash = #{dataHash,jdbcType=VARCHAR},
+ src_hash = #{srcHash,jdbcType=VARCHAR}
where id = #{id}
</update>
diff --git a/sonar-core/src/main/resources/org/sonar/core/user/AuthorizationMapper.xml b/sonar-core/src/main/resources/org/sonar/core/user/AuthorizationMapper.xml
index 12e1e32da23..1e757eaf58b 100644
--- a/sonar-core/src/main/resources/org/sonar/core/user/AuthorizationMapper.xml
+++ b/sonar-core/src/main/resources/org/sonar/core/user/AuthorizationMapper.xml
@@ -30,6 +30,33 @@
<foreach collection="componentKeys" open="(" close=")" item="element" index="index" separator=" or " >p.kee=#{element}</foreach>
</select>
+ <select id="keepAuthorizedProjectIdsForUser" parameterType="map" resultType="long">
+ SELECT gr.resource_id
+ FROM group_roles gr
+ WHERE
+ gr.role=#{role}
+ and (gr.group_id is null or gr.group_id in (select gu.group_id from groups_users gu where gu.user_id=#{userId}))
+ and
+ <foreach collection="componentIds" open="(" close=")" item="element" index="index" separator=" or ">gr.resource_id=#{element}</foreach>
+ UNION
+ SELECT p.id
+ FROM user_roles ur, projects p
+ WHERE
+ ur.role=#{role}
+ and ur.user_id=#{userId} and
+ <foreach collection="componentIds" open="(" close=")" item="element" index="index" separator=" or ">p.id=#{element}</foreach>
+ </select>
+
+ <select id="keepAuthorizedProjectIdsForAnonymous" parameterType="map" resultType="long">
+ SELECT gr.resource_id
+ FROM group_roles gr
+ WHERE
+ gr.role=#{role}
+ and gr.group_id is null
+ and
+ <foreach collection="componentIds" open="(" close=")" item="element" index="index" separator=" or ">gr.resource_id=#{element}</foreach>
+ </select>
+
<select id="selectAuthorizedRootProjectsKeys" parameterType="map" resultType="string">
<include refid="selectAuthorizedRootProjectsKeysQuery" />
</select>
diff --git a/sonar-core/src/main/resources/org/sonar/core/user/UserMapper.xml b/sonar-core/src/main/resources/org/sonar/core/user/UserMapper.xml
index 16b370594d7..aab09322e5d 100644
--- a/sonar-core/src/main/resources/org/sonar/core/user/UserMapper.xml
+++ b/sonar-core/src/main/resources/org/sonar/core/user/UserMapper.xml
@@ -23,25 +23,14 @@
WHERE u.login=#{login}
</select>
- <select id="selectNullableByScmAccountOrLoginOrEmail" parameterType="String" resultType="User">
+ <select id="selectNullableByScmAccountOrLoginOrEmail" parameterType="map" resultType="User">
SELECT
<include refid="userColumns"/>
FROM users u
WHERE
u.login=#{scmAccount}
OR u.email=#{scmAccount}
- OR
- <choose>
- <when test="_databaseId == 'mssql'">
- u.scm_accounts LIKE '%,' + #{scmAccount} + ',%'
- </when>
- <when test="_databaseId == 'mysql'">
- u.scm_accounts LIKE concat('%,', #{scmAccount}, ',%')
- </when>
- <otherwise>
- u.scm_accounts LIKE '%,' || #{scmAccount} || ',%'
- </otherwise>
- </choose>
+ OR u.scm_accounts like #{likeScmAccount}
</select>
<select id="selectUser" parameterType="long" resultType="User">
@@ -130,16 +119,18 @@
</delete>
<update id="deactivateUser" parameterType="long">
- UPDATE users SET active=${_false}, updated_at=#{now} WHERE id=#{id}
+ UPDATE users SET active=${_false}, updated_at=#{now,jdbcType=BIGINT} WHERE id=#{id}
</update>
<insert id="insert" parameterType="User" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
INSERT INTO users (login, name, email, active, scm_accounts, salt, crypted_password, created_at, updated_at)
- VALUES (#{login}, #{name}, #{email}, #{active}, #{scmAccounts}, #{salt}, #{cryptedPassword}, #{createdAt}, #{updatedAt})
+ VALUES (#{login,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{active,jdbcType=BOOLEAN}, #{scmAccounts,jdbcType=VARCHAR},
+ #{salt,jdbcType=VARCHAR}, #{cryptedPassword,jdbcType=VARCHAR}, #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT})
</insert>
<insert id="update" parameterType="User" useGeneratedKeys="false">
- UPDATE users set name=#{name}, email=#{email}, active=#{active}, scm_accounts=#{scmAccounts}, salt=#{salt}, crypted_password=#{cryptedPassword}, updated_at=#{updatedAt}
+ UPDATE users set name=#{name,jdbcType=VARCHAR}, email=#{email,jdbcType=VARCHAR}, active=#{active,jdbcType=BOOLEAN}, scm_accounts=#{scmAccounts,jdbcType=VARCHAR},
+ salt=#{salt,jdbcType=VARCHAR}, crypted_password=#{cryptedPassword,jdbcType=BIGINT}, updated_at=#{updatedAt,jdbcType=BIGINT}
WHERE login = #{login}
</insert>
diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
index 3698bebfe19..cd2218dda4a 100644
--- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties
+++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
@@ -1088,6 +1088,7 @@ select2.tooShort=Please enter at least {0} characters
widgets.more=More
widget.error_occurred_please_read_logs=An error occurred while trying to display the widget "{0}". Please contact the administrator.
widget.unsupported_browser_warning=Your browser is out of date and does not support this widget.
+widget.as_calculated_on_x=As calculated on {0}
widget.alerts.name=Quality Gate
widget.alerts.description=Displays the project's quality gate status.
diff --git a/sonar-core/src/test/java/org/sonar/core/component/ComponentDtoTest.java b/sonar-core/src/test/java/org/sonar/core/component/ComponentDtoTest.java
index 52fe57359e7..172164cb1c2 100644
--- a/sonar-core/src/test/java/org/sonar/core/component/ComponentDtoTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/component/ComponentDtoTest.java
@@ -21,6 +21,8 @@
package org.sonar.core.component;
import org.junit.Test;
+import org.sonar.api.resources.Qualifiers;
+import org.sonar.api.resources.Scopes;
import static org.assertj.core.api.Assertions.assertThat;
@@ -70,4 +72,11 @@ public class ComponentDtoTest {
assertThat(dto.hashCode()).isEqualTo(dtoWithSameId.hashCode());
assertThat(dto.hashCode()).isNotEqualTo(dtoWithDifferentId.hashCode());
}
+
+ @Test
+ public void is_root_project() throws Exception {
+ assertThat(new ComponentDto().setModuleUuid("ABCD").isRootProject()).isFalse();
+ assertThat(new ComponentDto().setModuleUuid("ABCD").setScope(Scopes.DIRECTORY).isRootProject()).isFalse();
+ assertThat(new ComponentDto().setModuleUuid(null).setScope(Scopes.PROJECT).setQualifier(Qualifiers.PROJECT).isRootProject()).isTrue();
+ }
}
diff --git a/sonar-core/src/test/java/org/sonar/core/component/ComponentKeysTest.java b/sonar-core/src/test/java/org/sonar/core/component/ComponentKeysTest.java
index 650996e9c8d..6ec3ca28536 100644
--- a/sonar-core/src/test/java/org/sonar/core/component/ComponentKeysTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/component/ComponentKeysTest.java
@@ -35,7 +35,7 @@ public class ComponentKeysTest {
Project project = new Project("my_project");
assertThat(ComponentKeys.createEffectiveKey(project, project)).isEqualTo("my_project");
- Directory dir = Directory.create("src/org/foo", "org/foo");
+ Directory dir = Directory.create("src/org/foo");
assertThat(ComponentKeys.createEffectiveKey(project, dir)).isEqualTo("my_project:src/org/foo");
Library library = new Library("junit:junit", "4.7");
diff --git a/sonar-core/src/test/java/org/sonar/core/component/ResourceComponentTest.java b/sonar-core/src/test/java/org/sonar/core/component/ResourceComponentTest.java
index de50b2ceb5a..ef2644a5b86 100644
--- a/sonar-core/src/test/java/org/sonar/core/component/ResourceComponentTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/component/ResourceComponentTest.java
@@ -34,7 +34,7 @@ public class ResourceComponentTest {
@Before
public void prepare() {
- file = new File("foo.c").setEffectiveKey("myproject:path/to/foo.c");
+ file = File.create("foo.c").setEffectiveKey("myproject:path/to/foo.c");
file.setKey("path/to/foo.c");
}
@@ -67,7 +67,7 @@ public class ResourceComponentTest {
@Test
public void effective_key_should_be_set() {
try {
- File file = new File("foo.c");
+ File file = File.create("foo.c");
new ResourceComponent(file);
fail();
} catch (IllegalArgumentException e) {
diff --git a/sonar-core/src/test/java/org/sonar/core/persistence/DaoUtilsTest.java b/sonar-core/src/test/java/org/sonar/core/persistence/DaoUtilsTest.java
index db891b609ec..03e1d41d380 100644
--- a/sonar-core/src/test/java/org/sonar/core/persistence/DaoUtilsTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/persistence/DaoUtilsTest.java
@@ -19,11 +19,16 @@
*/
package org.sonar.core.persistence;
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
import org.junit.Test;
+import java.util.Collections;
import java.util.List;
+import static com.google.common.collect.Lists.newArrayList;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
public class DaoUtilsTest {
@@ -38,6 +43,44 @@ public class DaoUtilsTest {
public void repeatCondition() throws Exception {
assertThat(DaoUtils.repeatCondition("uuid=?", 1, "or")).isEqualTo("uuid=?");
assertThat(DaoUtils.repeatCondition("uuid=?", 3, "or")).isEqualTo("uuid=? or uuid=? or uuid=?");
+ }
+
+ @Test
+ public void execute_large_inputs() throws Exception {
+ List<Integer> inputs = newArrayList();
+ List<String> expectedOutputs = newArrayList();
+ for (int i = 0; i < 2010; i++) {
+ inputs.add(i);
+ expectedOutputs.add(Integer.toString(i));
+ }
+
+ List<String> outputs = DaoUtils.executeLargeInputs(inputs, new Function<List<Integer>, List<String>>() {
+ @Override
+ public List<String> apply(List<Integer> input) {
+ // Check that each partition is only done on 1000 elements max
+ assertThat(input.size()).isLessThanOrEqualTo(1000);
+ return newArrayList(Iterables.transform(input, new Function<Integer, String>() {
+ @Override
+ public String apply(Integer input) {
+ return Integer.toString(input);
+ }
+ }));
+ }
+ });
+
+ assertThat(outputs).isEqualTo(expectedOutputs);
+ }
+
+ @Test
+ public void execute_large_inputs_on_empty_list() throws Exception {
+ List<String> outputs = DaoUtils.executeLargeInputs(Collections.<Integer>emptyList(), new Function<List<Integer>, List<String>>() {
+ @Override
+ public List<String> apply(List<Integer> input) {
+ fail("No partition should be made on empty list");
+ return Collections.emptyList();
+ }
+ });
+ assertThat(outputs).isEmpty();
}
}
diff --git a/sonar-core/src/test/java/org/sonar/core/persistence/SemaphoreDaoTest.java b/sonar-core/src/test/java/org/sonar/core/persistence/SemaphoreDaoTest.java
index a2652f1aaa1..6d9c6d74eb1 100644
--- a/sonar-core/src/test/java/org/sonar/core/persistence/SemaphoreDaoTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/persistence/SemaphoreDaoTest.java
@@ -19,15 +19,14 @@
*/
package org.sonar.core.persistence;
-import org.apache.commons.lang.time.DateUtils;
import org.apache.ibatis.session.SqlSession;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.Semaphores;
+import org.sonar.api.utils.System2;
-import java.util.Date;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.atomic.AtomicInteger;
@@ -36,23 +35,33 @@ import static org.assertj.core.api.Assertions.assertThat;
public class SemaphoreDaoTest extends AbstractDaoTestCase {
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
private SemaphoreDao dao;
+ private System2 system;
@Before
public void before() {
- dao = new SemaphoreDao(getMyBatis());
+ system = System2.INSTANCE;
+ dao = new SemaphoreDao(getMyBatis(), system);
}
- @Rule
- public ExpectedException thrown = ExpectedException.none();
+ @Test
+ public void should_fail_to_acquire_if_null_semaphore_name() {
+ thrown.expect(IllegalArgumentException.class);
+ thrown.expectMessage("Semaphore name must not be empty");
+
+ SemaphoreDao dao = new SemaphoreDao(getMyBatis(), system);
+ dao.acquire(null, 5000);
+ }
@Test
public void should_fail_to_acquire_if_blank_semaphore_name() {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Semaphore name must not be empty");
- SemaphoreDao dao = new SemaphoreDao(getMyBatis());
- dao.acquire(null, 5000);
+ SemaphoreDao dao = new SemaphoreDao(getMyBatis(), system);
+ dao.acquire("", 5000);
}
@Test
@@ -60,7 +69,7 @@ public class SemaphoreDaoTest extends AbstractDaoTestCase {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Semaphore max age must be positive: -5000");
- SemaphoreDao dao = new SemaphoreDao(getMyBatis());
+ SemaphoreDao dao = new SemaphoreDao(getMyBatis(), system);
dao.acquire("foo", -5000);
}
@@ -69,7 +78,7 @@ public class SemaphoreDaoTest extends AbstractDaoTestCase {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Semaphore name must not be empty");
- SemaphoreDao dao = new SemaphoreDao(getMyBatis());
+ SemaphoreDao dao = new SemaphoreDao(getMyBatis(), system);
dao.release(null);
}
@@ -97,20 +106,28 @@ public class SemaphoreDaoTest extends AbstractDaoTestCase {
assertThat(lock.getDurationSinceLocked()).isNull();
SemaphoreDto semaphore = selectSemaphore("foo");
- assertThat(semaphore.getCreatedAt().getTime()).isEqualTo(semaphore.getUpdatedAt().getTime());
+ assertThat(semaphore.getCreatedAt()).isEqualTo(semaphore.getUpdatedAt());
Thread.sleep(1000);
dao.update(lock);
semaphore = selectSemaphore("foo");
- assertThat(semaphore.getCreatedAt().getTime()).isLessThan(semaphore.getUpdatedAt().getTime());
+ assertThat(semaphore.getCreatedAt()).isLessThan(semaphore.getUpdatedAt());
dao.release("foo");
assertThat(selectSemaphore("foo")).isNull();
}
@Test
+ public void fail_to_update_null_semaphore() throws Exception {
+ thrown.expect(IllegalArgumentException.class);
+ thrown.expectMessage("Semaphore must not be null");
+
+ dao.update(null);
+ }
+
+ @Test
public void create_and_acquire_semaphore_when_maxage_is_zeo() throws Exception {
Semaphores.Semaphore lock = dao.acquire("foo", 0);
assertThat(lock.isLocked()).isTrue();
@@ -247,19 +264,11 @@ public class SemaphoreDaoTest extends AbstractDaoTestCase {
}
}
- private boolean isRecent(Date date) {
- Date future = DateUtils.addMinutes(now(), 1);
- Date past = DateUtils.addDays(now(), -1);
- return date.after(past) && date.before(future);
- }
-
- private Date now() {
- SqlSession session = getMyBatis().openSession();
- try {
- return dao.now(session);
- } finally {
- MyBatis.closeQuietly(session);
- }
+ private boolean isRecent(Long date) {
+ int oneMinuteInMs = 60 * 1000;
+ long future = system.now() + oneMinuteInMs;
+ long past = system.now() - oneMinuteInMs;
+ return date > past && date < future;
}
private static class Runner extends Thread {
diff --git a/sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java b/sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java
index ef6948a8c21..56b56b5fe15 100644
--- a/sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java
@@ -345,7 +345,7 @@ public class ResourceDaoTest extends AbstractDaoTestCase {
setupData("fixture");
assertThat(dao.findByKey("org.struts:struts")).isNotNull();
- Component<?> component = dao.findByKey("org.struts:struts-core:src/org/struts/RequestContext.java");
+ Component component = dao.findByKey("org.struts:struts-core:src/org/struts/RequestContext.java");
assertThat(component).isNotNull();
assertThat(component.path()).isEqualTo("src/org/struts/RequestContext.java");
assertThat(dao.findByKey("unknown")).isNull();
diff --git a/sonar-core/src/test/java/org/sonar/core/source/db/FileSourceDaoTest.java b/sonar-core/src/test/java/org/sonar/core/source/db/FileSourceDaoTest.java
index dc8dc262db2..aed0f04fd71 100644
--- a/sonar-core/src/test/java/org/sonar/core/source/db/FileSourceDaoTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/source/db/FileSourceDaoTest.java
@@ -25,13 +25,12 @@ import org.apache.commons.io.IOUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.sonar.api.utils.DateUtils;
import org.sonar.core.persistence.AbstractDaoTestCase;
import org.sonar.core.persistence.DbSession;
import java.io.IOException;
+import java.io.InputStream;
import java.io.Reader;
-import java.util.Date;
import static org.assertj.core.api.Assertions.assertThat;
@@ -56,77 +55,82 @@ public class FileSourceDaoTest extends AbstractDaoTestCase {
public void select() throws Exception {
setupData("shared");
- FileSourceDto fileSourceDto = dao.select("ab12");
+ FileSourceDto fileSourceDto = dao.select("FILE1_UUID");
- assertThat(fileSourceDto.getData()).isEqualTo("aef12a,alice,2014-04-25T12:34:56+0100,,class Foo");
+ assertThat(fileSourceDto.getBinaryData()).isNotEmpty();
assertThat(fileSourceDto.getDataHash()).isEqualTo("hash");
- assertThat(fileSourceDto.getProjectUuid()).isEqualTo("abcd");
- assertThat(fileSourceDto.getFileUuid()).isEqualTo("ab12");
- assertThat(new Date(fileSourceDto.getCreatedAt())).isEqualTo(DateUtils.parseDateTime("2014-10-29T16:44:02+0100"));
- assertThat(new Date(fileSourceDto.getUpdatedAt())).isEqualTo(DateUtils.parseDateTime("2014-10-30T16:44:02+0100"));
+ assertThat(fileSourceDto.getProjectUuid()).isEqualTo("PRJ_UUID");
+ assertThat(fileSourceDto.getFileUuid()).isEqualTo("FILE1_UUID");
+ assertThat(fileSourceDto.getCreatedAt()).isEqualTo(1500000000000L);
+ assertThat(fileSourceDto.getUpdatedAt()).isEqualTo(1500000000000L);
}
@Test
public void select_data() throws Exception {
setupData("shared");
- StringParser stringParser = new StringParser();
- dao.readDataStream("ab12", stringParser);
+ InputStreamToStringFunction fn = new InputStreamToStringFunction();
+ dao.readDataStream("FILE1_UUID", fn);
- assertThat(stringParser.getResult()).isEqualTo("aef12a,alice,2014-04-25T12:34:56+0100,,class Foo");
+ assertThat(fn.result).isNotEmpty();
}
@Test
public void select_line_hashes() throws Exception {
setupData("shared");
- StringParser stringParser = new StringParser();
- dao.readLineHashesStream(session, "ab12", stringParser);
+ ReaderToStringFunction fn = new ReaderToStringFunction();
+ dao.readLineHashesStream(session, "FILE1_UUID", fn);
- assertThat(stringParser.getResult()).isEqualTo("truc");
+ assertThat(fn.result).isEqualTo("ABC\\nDEF\\nGHI");
}
@Test
public void no_line_hashes_on_unknown_file() throws Exception {
setupData("shared");
- StringParser stringParser = new StringParser();
- dao.readLineHashesStream(session, "unknown", stringParser);
+ ReaderToStringFunction fn = new ReaderToStringFunction();
+ dao.readLineHashesStream(session, "unknown", fn);
- assertThat(stringParser.getResult()).isEmpty();
+ assertThat(fn.result).isNull();
}
@Test
public void insert() throws Exception {
setupData("shared");
- dao.insert(new FileSourceDto().setProjectUuid("prj").setFileUuid("file").setData("bla bla")
- .setDataHash("hash2")
- .setLineHashes("foo\nbar")
- .setSrcHash("hache")
- .setCreatedAt(DateUtils.parseDateTime("2014-10-31T16:44:02+0100").getTime())
- .setUpdatedAt(DateUtils.parseDateTime("2014-10-31T16:44:02+0100").getTime()));
-
- checkTable("insert", "file_sources");
+ dao.insert(new FileSourceDto()
+ .setProjectUuid("PRJ_UUID")
+ .setFileUuid("FILE2_UUID")
+ .setBinaryData("FILE2_BINARY_DATA".getBytes())
+ .setDataHash("FILE2_DATA_HASH")
+ .setLineHashes("LINE1_HASH\\nLINE2_HASH")
+ .setSrcHash("FILE2_HASH")
+ .setCreatedAt(1500000000000L)
+ .setUpdatedAt(1500000000001L));
+
+ checkTable("insert", "file_sources", "project_uuid", "file_uuid", "data_hash", "line_hashes", "src_hash", "created_at", "updated_at");
}
@Test
public void update() throws Exception {
setupData("shared");
- dao.update(new FileSourceDto().setId(101L).setProjectUuid("prj").setFileUuid("file")
- .setData("updated data")
- .setDataHash("hash2")
- .setSrcHash("123456")
- .setLineHashes("foo2\nbar2")
- .setUpdatedAt(DateUtils.parseDateTime("2014-10-31T16:44:02+0100").getTime()));
+ dao.update(new FileSourceDto().setId(101L)
+ .setProjectUuid("PRJ_UUID")
+ .setFileUuid("FILE1_UUID")
+ .setBinaryData("updated data".getBytes())
+ .setDataHash("NEW_DATA_HASH")
+ .setSrcHash("NEW_FILE_HASH")
+ .setLineHashes("NEW_LINE_HASHES")
+ .setUpdatedAt(1500000000002L));
- checkTable("update", "file_sources");
+ checkTable("update", "file_sources", "project_uuid", "file_uuid", "data_hash", "line_hashes", "src_hash", "created_at", "updated_at");
}
- class StringParser implements Function<Reader, String> {
+ private static class ReaderToStringFunction implements Function<Reader, String> {
- String result = "";
+ String result = null;
@Override
public String apply(Reader input) {
@@ -137,9 +141,20 @@ public class FileSourceDaoTest extends AbstractDaoTestCase {
throw new RuntimeException(e);
}
}
+ }
+
+ private static class InputStreamToStringFunction implements Function<InputStream, String> {
- public String getResult() {
- return result;
+ String result = null;
+
+ @Override
+ public String apply(InputStream input) {
+ try {
+ result = IOUtils.toString(input);
+ return IOUtils.toString(input);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
}
}
}
diff --git a/sonar-core/src/test/java/org/sonar/core/user/AuthorizationDaoTest.java b/sonar-core/src/test/java/org/sonar/core/user/AuthorizationDaoTest.java
index 2e267d391ad..521d0af66a3 100644
--- a/sonar-core/src/test/java/org/sonar/core/user/AuthorizationDaoTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/user/AuthorizationDaoTest.java
@@ -20,19 +20,33 @@
package org.sonar.core.user;
import com.google.common.collect.Sets;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
import org.sonar.core.persistence.AbstractDaoTestCase;
+import org.sonar.core.persistence.DbSession;
import java.util.Collection;
-import java.util.Set;
import static org.assertj.core.api.Assertions.assertThat;
public class AuthorizationDaoTest extends AbstractDaoTestCase {
private static final int USER = 100;
- private static final String PROJECT = "pj-w-snapshot", PACKAGE = "pj-w-snapshot:package", FILE = "pj-w-snapshot:file", FILE_IN_OTHER_PROJECT = "another",
- EMPTY_PROJECT = "pj-wo-snapshot";
+ private static final Long PROJECT_ID = 300L, EMPTY_PROJECT_ID = 400L;
+ private static final String PROJECT = "pj-w-snapshot";
+
+ DbSession session;
+
+ @Before
+ public void setUp() throws Exception {
+ session = getMyBatis().openSession(false);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ session.close();
+ }
@Test
public void user_should_be_authorized() {
@@ -40,15 +54,15 @@ public class AuthorizationDaoTest extends AbstractDaoTestCase {
setupData("user_should_be_authorized");
AuthorizationDao authorization = new AuthorizationDao(getMyBatis());
- Set<String> componentIds = authorization.keepAuthorizedComponentKeys(
- Sets.<String>newHashSet(PROJECT, PACKAGE, FILE, FILE_IN_OTHER_PROJECT, EMPTY_PROJECT),
+ Collection<Long> componentIds = authorization.keepAuthorizedProjectIds(session,
+ Sets.newHashSet(PROJECT_ID, EMPTY_PROJECT_ID),
USER, "user");
- assertThat(componentIds).containsOnly(PROJECT, PACKAGE, FILE, EMPTY_PROJECT);
+ assertThat(componentIds).containsOnly(PROJECT_ID, EMPTY_PROJECT_ID);
// user does not have the role "admin"
- componentIds = authorization.keepAuthorizedComponentKeys(
- Sets.<String>newHashSet(PROJECT, PACKAGE, FILE),
+ componentIds = authorization.keepAuthorizedProjectIds(session,
+ Sets.newHashSet(PROJECT_ID),
USER, "admin");
assertThat(componentIds).isEmpty();
}
@@ -72,15 +86,15 @@ public class AuthorizationDaoTest extends AbstractDaoTestCase {
setupData("group_should_be_authorized");
AuthorizationDao authorization = new AuthorizationDao(getMyBatis());
- Set<String> componentIds = authorization.keepAuthorizedComponentKeys(
- Sets.<String>newHashSet(PROJECT, PACKAGE, FILE, FILE_IN_OTHER_PROJECT, EMPTY_PROJECT),
+ Collection<Long> componentIds = authorization.keepAuthorizedProjectIds(session,
+ Sets.newHashSet(PROJECT_ID, EMPTY_PROJECT_ID),
USER, "user");
- assertThat(componentIds).containsOnly(PROJECT, PACKAGE, FILE, EMPTY_PROJECT);
+ assertThat(componentIds).containsOnly(PROJECT_ID, EMPTY_PROJECT_ID);
// group does not have the role "admin"
- componentIds = authorization.keepAuthorizedComponentKeys(
- Sets.<String>newHashSet(PROJECT, PACKAGE, FILE, FILE_IN_OTHER_PROJECT, EMPTY_PROJECT),
+ componentIds = authorization.keepAuthorizedProjectIds(session,
+ Sets.newHashSet(PROJECT_ID, EMPTY_PROJECT_ID),
USER, "admin");
assertThat(componentIds).isEmpty();
}
@@ -91,15 +105,15 @@ public class AuthorizationDaoTest extends AbstractDaoTestCase {
setupData("group_should_have_global_authorization");
AuthorizationDao authorization = new AuthorizationDao(getMyBatis());
- Set<String> componentIds = authorization.keepAuthorizedComponentKeys(
- Sets.<String>newHashSet(PROJECT, PACKAGE, FILE, FILE_IN_OTHER_PROJECT, EMPTY_PROJECT),
+ Collection<Long> componentIds = authorization.keepAuthorizedProjectIds(session,
+ Sets.newHashSet(PROJECT_ID, EMPTY_PROJECT_ID),
USER, "user");
- assertThat(componentIds).containsOnly(PROJECT, PACKAGE, FILE, EMPTY_PROJECT);
+ assertThat(componentIds).containsOnly(PROJECT_ID, EMPTY_PROJECT_ID);
// group does not have the role "admin"
- componentIds = authorization.keepAuthorizedComponentKeys(
- Sets.<String>newHashSet(PROJECT, PACKAGE, FILE, FILE_IN_OTHER_PROJECT, EMPTY_PROJECT),
+ componentIds = authorization.keepAuthorizedProjectIds(session,
+ Sets.newHashSet(PROJECT_ID, EMPTY_PROJECT_ID),
USER, "admin");
assertThat(componentIds).isEmpty();
}
@@ -109,15 +123,15 @@ public class AuthorizationDaoTest extends AbstractDaoTestCase {
setupData("anonymous_should_be_authorized");
AuthorizationDao authorization = new AuthorizationDao(getMyBatis());
- Set<String> componentIds = authorization.keepAuthorizedComponentKeys(
- Sets.<String>newHashSet(PROJECT, PACKAGE, FILE, FILE_IN_OTHER_PROJECT, EMPTY_PROJECT),
+ Collection<Long> componentIds = authorization.keepAuthorizedProjectIds(session,
+ Sets.newHashSet(PROJECT_ID, EMPTY_PROJECT_ID),
null, "user");
- assertThat(componentIds).containsOnly(PROJECT, PACKAGE, FILE, EMPTY_PROJECT);
+ assertThat(componentIds).containsOnly(PROJECT_ID, EMPTY_PROJECT_ID);
// group does not have the role "admin"
- componentIds = authorization.keepAuthorizedComponentKeys(
- Sets.<String>newHashSet(PROJECT, PACKAGE, FILE, FILE_IN_OTHER_PROJECT),
+ componentIds = authorization.keepAuthorizedProjectIds(session,
+ Sets.newHashSet(PROJECT_ID),
null, "admin");
assertThat(componentIds).isEmpty();
}
diff --git a/sonar-core/src/test/java/org/sonar/core/user/UserDtoTest.java b/sonar-core/src/test/java/org/sonar/core/user/UserDtoTest.java
new file mode 100644
index 00000000000..23150850e60
--- /dev/null
+++ b/sonar-core/src/test/java/org/sonar/core/user/UserDtoTest.java
@@ -0,0 +1,45 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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 this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.core.user;
+
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.Collections;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class UserDtoTest {
+
+ @Test
+ public void encode_scm_accounts() throws Exception {
+ assertThat(UserDto.encodeScmAccounts(null)).isNull();
+ assertThat(UserDto.encodeScmAccounts(Collections.<String>emptyList())).isNull();
+ assertThat(UserDto.encodeScmAccounts(Arrays.asList("foo"))).isEqualTo("\nfoo\n");
+ assertThat(UserDto.encodeScmAccounts(Arrays.asList("foo", "bar"))).isEqualTo("\nfoo\nbar\n");
+ }
+
+ @Test
+ public void decode_scm_accounts() throws Exception {
+ assertThat(UserDto.decodeScmAccounts(null)).isEmpty();
+ assertThat(UserDto.decodeScmAccounts("\nfoo\n")).containsOnly("foo");
+ assertThat(UserDto.decodeScmAccounts("\nfoo\nbar\n")).containsOnly("foo", "bar");
+ }
+}
diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/ActionPlanStatsDaoTest/should_find_by_project.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/ActionPlanStatsDaoTest/should_find_by_project.xml
index e945efb6ab0..574573ee9f7 100644
--- a/sonar-core/src/test/resources/org/sonar/core/issue/db/ActionPlanStatsDaoTest/should_find_by_project.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/ActionPlanStatsDaoTest/should_find_by_project.xml
@@ -21,9 +21,9 @@
author_login="[null]"
issue_attributes="JIRA=FOO-1234"
action_plan_key="ABC"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="1400000000000"
updated_at="1400000000000"
/>
@@ -46,9 +46,9 @@
author_login="[null]"
issue_attributes="JIRA=FOO-1234"
action_plan_key="ABC"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="1400000000000"
updated_at="1400000000000"
/>
@@ -71,9 +71,9 @@
author_login="[null]"
issue_attributes="JIRA=FOO-1234"
action_plan_key="ABC"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="1400000000000"
updated_at="1400000000000"
/>
diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueChangeDaoTest/select_issue_changelog_by_module.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueChangeDaoTest/select_issue_changelog_by_module.xml
index 6b43a944834..fd4ee9c31d0 100644
--- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueChangeDaoTest/select_issue_changelog_by_module.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueChangeDaoTest/select_issue_changelog_by_module.xml
@@ -24,9 +24,9 @@
assignee="user"
author_login="[null]"
issue_attributes="[null]"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="1400000000000"
updated_at="[null]"
/>
@@ -86,9 +86,9 @@
assignee="user"
author_login="[null]"
issue_attributes="[null]"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="1400000000000"
updated_at="[null]"
/>
@@ -124,9 +124,9 @@
assignee="user"
author_login="[null]"
issue_attributes="[null]"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="1400000000000"
updated_at="[null]"
/>
@@ -162,9 +162,9 @@
assignee="user"
author_login="[null]"
issue_attributes="[null]"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="1400000000000"
updated_at="[null]"
/>
@@ -200,9 +200,9 @@
assignee="user"
author_login="[null]"
issue_attributes="[null]"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="1400000000000"
updated_at="[null]"
/>
diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueChangeDaoTest/select_issue_changelog_by_module_are_sorted_by_creation_date.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueChangeDaoTest/select_issue_changelog_by_module_are_sorted_by_creation_date.xml
index 88ce001bcc3..b019869a390 100644
--- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueChangeDaoTest/select_issue_changelog_by_module_are_sorted_by_creation_date.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueChangeDaoTest/select_issue_changelog_by_module_are_sorted_by_creation_date.xml
@@ -21,9 +21,9 @@
assignee="user"
author_login="[null]"
issue_attributes="[null]"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="1400000000000"
updated_at="[null]"
/>
diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/find_rules_by_component.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/find_rules_by_component.xml
index 3b0a6b64d2b..9d97be65b71 100644
--- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/find_rules_by_component.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/find_rules_by_component.xml
@@ -19,9 +19,9 @@
assignee="perceval"
author_login="[null]"
issue_attributes="JIRA=FOO-1234"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="1400000000000"
updated_at="1400000000000"
/>
@@ -44,9 +44,9 @@
assignee="perceval"
author_login="[null]"
issue_attributes="JIRA=FOO-1234"
- issue_creation_date="2013-04-17"
- issue_update_date="2013-04-17"
- issue_close_date="2013-04-17"
+ issue_creation_date="1366149600000"
+ issue_update_date="1366149600000"
+ issue_close_date="1366149600000"
created_at="1400000000000"
updated_at="1400000000000"
/>
@@ -71,9 +71,9 @@
assignee="perceval"
author_login="[null]"
issue_attributes="JIRA=FOO-1234"
- issue_creation_date="2013-04-18"
- issue_update_date="2013-04-18"
- issue_close_date="2013-04-18"
+ issue_creation_date="1366236000000"
+ issue_update_date="1366236000000"
+ issue_close_date="1366236000000"
created_at="1400000000000"
updated_at="1400000000000"
/>
diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/find_severities_by_component.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/find_severities_by_component.xml
index 19d8d5c7105..054f2e5b877 100644
--- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/find_severities_by_component.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/find_severities_by_component.xml
@@ -19,9 +19,9 @@
assignee="perceval"
author_login="[null]"
issue_attributes="JIRA=FOO-1234"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="1400000000000"
updated_at="1400000000000"
/>
@@ -44,9 +44,9 @@
assignee="perceval"
author_login="[null]"
issue_attributes="JIRA=FOO-1234"
- issue_creation_date="2013-04-17"
- issue_update_date="2013-04-17"
- issue_close_date="2013-04-17"
+ issue_creation_date="1366149600000"
+ issue_update_date="1366149600000"
+ issue_close_date="1366149600000"
created_at="1400000000000"
updated_at="1400000000000"
/>
@@ -71,9 +71,9 @@
assignee="perceval"
author_login="[null]"
issue_attributes="JIRA=FOO-1234"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="1400000000000"
updated_at="1400000000000"
/>
diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_key.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_key.xml
index 4faf9b16db0..080269cef46 100644
--- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_key.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_key.xml
@@ -18,9 +18,9 @@
assignee="perceval"
author_login="karadoc"
issue_attributes="JIRA=FOO-1234"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="1400000000000"
updated_at="1400000000000"
/>
diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_issue_and_component_ids.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_issue_and_component_ids.xml
index a8a8d8eafa3..014ca75c7d5 100644
--- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_issue_and_component_ids.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_issue_and_component_ids.xml
@@ -19,9 +19,9 @@
assignee="perceval"
author_login="[null]"
issue_attributes="JIRA=FOO-1234"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="1400000000000"
updated_at="1400000000000"
/>
@@ -44,9 +44,9 @@
assignee="perceval"
author_login="[null]"
issue_attributes="JIRA=FOO-1234"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="1400000000000"
updated_at="1400000000000"
/>
@@ -71,9 +71,9 @@
assignee="perceval"
author_login="[null]"
issue_attributes="JIRA=FOO-1234"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="1400000000000"
updated_at="1400000000000"
/>
diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_non_closed_issues_by_module.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_non_closed_issues_by_module.xml
index 06824c52449..3a0b7ee023d 100644
--- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_non_closed_issues_by_module.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_non_closed_issues_by_module.xml
@@ -19,9 +19,9 @@
assignee="user"
author_login="[null]"
issue_attributes="[null]"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="1400000000000"
updated_at="[null]"
/>
@@ -45,9 +45,9 @@
assignee="user"
author_login="[null]"
issue_attributes="[null]"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="1400000000000"
updated_at="[null]"
/>
@@ -71,9 +71,9 @@
assignee="user"
author_login="[null]"
issue_attributes="[null]"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="1400000000000"
updated_at="[null]"
/>
@@ -97,9 +97,9 @@
assignee="user"
author_login="[null]"
issue_attributes="[null]"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="1400000000000"
updated_at="[null]"
/>
@@ -123,9 +123,9 @@
assignee="user"
author_login="[null]"
issue_attributes="[null]"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="1400000000000"
updated_at="[null]"
/>
diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_non_closed_issues_by_module_on_removed_project.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_non_closed_issues_by_module_on_removed_project.xml
index 53906e7d6e5..b7b17a65dd3 100644
--- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_non_closed_issues_by_module_on_removed_project.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_non_closed_issues_by_module_on_removed_project.xml
@@ -39,9 +39,9 @@
assignee="user"
author_login="[null]"
issue_attributes="[null]"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="1400000000000"
updated_at="[null]"
/>
@@ -65,9 +65,9 @@
assignee="user"
author_login="[null]"
issue_attributes="[null]"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="1400000000000"
updated_at="[null]"
/>
@@ -91,9 +91,9 @@
assignee="user"
author_login="[null]"
issue_attributes="[null]"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="1400000000000"
updated_at="[null]"
/>
@@ -117,9 +117,9 @@
assignee="user"
author_login="[null]"
issue_attributes="[null]"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="1400000000000"
updated_at="[null]"
/>
diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testInsert-result.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testInsert-result.xml
index 19384f8380a..bbc47e84e7f 100644
--- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testInsert-result.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testInsert-result.xml
@@ -19,9 +19,9 @@
assignee="karadoc"
issue_attributes="JIRA=FOO-1234"
tags="[null]"
- issue_creation_date="2013-05-18"
- issue_update_date="2013-05-19"
- issue_close_date="2013-05-20"
+ issue_creation_date="1368828000000"
+ issue_update_date="1368914400000"
+ issue_close_date="1369000800000"
created_at="1400000000000"
updated_at="1500000000000"
action_plan_key="current_sprint"
diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testUpdate-result.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testUpdate-result.xml
index 5cf1714d9bb..148d47a907b 100644
--- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testUpdate-result.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testUpdate-result.xml
@@ -19,9 +19,9 @@
assignee="karadoc"
issue_attributes="JIRA=FOO-1234"
tags="[null]"
- issue_creation_date="2013-05-18"
- issue_update_date="2013-05-19"
- issue_close_date="2013-05-20"
+ issue_creation_date="1368828000000"
+ issue_update_date="1368914400000"
+ issue_close_date="1369000800000"
created_at="1400000000000"
updated_at="1500000000000"
action_plan_key="current_sprint"
diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStatsDaoTest/should_select_assignees.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStatsDaoTest/should_select_assignees.xml
index 1fd8a9ec17b..ce76408c323 100644
--- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStatsDaoTest/should_select_assignees.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStatsDaoTest/should_select_assignees.xml
@@ -21,9 +21,9 @@
assignee="perceval"
author_login="[null]"
issue_attributes="JIRA=FOO-1234"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="2013-04-16"
updated_at="2013-04-16"
/>
@@ -46,9 +46,9 @@
assignee="[null]"
author_login="[null]"
issue_attributes="JIRA=FOO-1234"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="2013-04-16"
updated_at="2013-04-16"
/>
@@ -71,9 +71,9 @@
assignee="perceval"
author_login="[null]"
issue_attributes="JIRA=FOO-1234"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="2013-04-16"
updated_at="2013-04-16"
/>
diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_insert_new_issues-result.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_insert_new_issues-result.xml
index e9701caee67..a69e0a72135 100644
--- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_insert_new_issues-result.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_insert_new_issues-result.xml
@@ -16,9 +16,9 @@
issue_attributes="foo=bar"
tags="[null]"
action_plan_key="[null]"
- issue_creation_date="2013-05-18"
- issue_update_date="2013-05-18"
- issue_close_date="2013-05-18"
+ issue_creation_date="1368828000000"
+ issue_update_date="1368828000000"
+ issue_close_date="1368828000000"
/>
<issue_changes id="1" kee="FGHIJ" issue_key="ABCDE" change_type="comment" user_login="emmerik"
diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_resolve_conflicts_on_updates-result.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_resolve_conflicts_on_updates-result.xml
index 9620376c137..30ba1970b6a 100644
--- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_resolve_conflicts_on_updates-result.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_resolve_conflicts_on_updates-result.xml
@@ -26,8 +26,8 @@
action_plan_key="[null]"
created_at="2005-05-12"
updated_at="2013-05-18"
- issue_creation_date="2005-05-12 00:00:00.0"
- issue_update_date="2013-05-18 00:00:00.0"
+ issue_creation_date="1115848800000"
+ issue_update_date="1368828000000"
issue_close_date="[null]"
/>
</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_resolve_conflicts_on_updates.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_resolve_conflicts_on_updates.xml
index 0346a0a03ea..b026a0da238 100644
--- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_resolve_conflicts_on_updates.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_resolve_conflicts_on_updates.xml
@@ -28,8 +28,8 @@
action_plan_key="[null]"
created_at="2005-05-12"
updated_at="2013-05-18"
- issue_creation_date="2005-05-12 00:00:00.0"
- issue_update_date="2013-05-18 00:00:00.0"
+ issue_creation_date="1115848800000"
+ issue_update_date="1368828000000"
issue_close_date="[null]"
/>
</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_update_issues-result.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_update_issues-result.xml
index 3cc73d72c7c..ea291ef00bc 100644
--- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_update_issues-result.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_update_issues-result.xml
@@ -21,9 +21,9 @@
issue_attributes="foo=bar"
tags="[null]"
action_plan_key="[null]"
- issue_creation_date="2013-05-18 00:00:00.0"
- issue_update_date="2013-05-18 00:00:00.0"
- issue_close_date="2013-05-18 00:00:00.0"
+ issue_creation_date="1368828000000"
+ issue_update_date="1368828000000"
+ issue_close_date="1368828000000"
/>
<issue_changes id="1" kee="FGHIJ" issue_key="ABCDE" change_type="comment" user_login="emmerik"
diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_update_issues.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_update_issues.xml
index cb130ab616c..971c9c75120 100644
--- a/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_update_issues.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_update_issues.xml
@@ -21,8 +21,8 @@
issue_attributes="foo=bar"
tags="[null]"
action_plan_key="[null]"
- issue_creation_date="2010-01-01"
- issue_update_date="2010-02-02"
+ issue_creation_date="1262300400000"
+ issue_update_date="1265065200000"
issue_close_date="[null]"
/>
</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/persistence/PreviewDatabaseFactoryTest/multi-modules-with-issues.xml b/sonar-core/src/test/resources/org/sonar/core/persistence/PreviewDatabaseFactoryTest/multi-modules-with-issues.xml
index f6847e78a1c..82a42cdbba9 100644
--- a/sonar-core/src/test/resources/org/sonar/core/persistence/PreviewDatabaseFactoryTest/multi-modules-with-issues.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/persistence/PreviewDatabaseFactoryTest/multi-modules-with-issues.xml
@@ -88,9 +88,9 @@
assignee="user"
author_login="[null]"
issue_attributes="[null]"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="[null]"
updated_at="[null]"
/>
@@ -114,9 +114,9 @@
assignee="user"
author_login="[null]"
issue_attributes="[null]"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="[null]"
updated_at="[null]"
/>
diff --git a/sonar-core/src/test/resources/org/sonar/core/persistence/PreviewDatabaseFactoryTest/should_create_database_with_issues.xml b/sonar-core/src/test/resources/org/sonar/core/persistence/PreviewDatabaseFactoryTest/should_create_database_with_issues.xml
index ea885325961..d66c716e4a3 100644
--- a/sonar-core/src/test/resources/org/sonar/core/persistence/PreviewDatabaseFactoryTest/should_create_database_with_issues.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/persistence/PreviewDatabaseFactoryTest/should_create_database_with_issues.xml
@@ -37,9 +37,9 @@
assignee="user"
author_login="[null]"
issue_attributes="[null]"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="[null]"
updated_at="[null]"
/>
@@ -62,9 +62,9 @@
assignee="user"
author_login="[null]"
issue_attributes="[null]"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="[null]"
updated_at="[null]"
/>
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 903ea7916c7..23a1d4ff67b 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" checksum="acbd18db4cc2f85cedef654fccc4a4d8" created_at="2010-01-25" updated_at="2010-01-25" locked_at="2010-01-25"/>
-</dataset> \ No newline at end of file
+ <semaphores id="1" name="foo" checksum="acbd18db4cc2f85cedef654fccc4a4d8" created_at="1264374000000" updated_at="1264374000000" locked_at="1264374000000"/>
+</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteResource.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteResource.xml
index 8912afe10d4..e7d8f49a2b4 100644
--- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteResource.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteResource.xml
@@ -23,9 +23,9 @@
reporter="perceval" assignee="arthur" rule_id="500"
manual_severity="[false]"
message="[null]"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
created_at="[null]"
updated_at="[null]"
/>
diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/delete_file_sources_of_disabled_resources-result.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/delete_file_sources_of_disabled_resources-result.xml
index 13b1c270dc4..7caaa526513 100644
--- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/delete_file_sources_of_disabled_resources-result.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/delete_file_sources_of_disabled_resources-result.xml
@@ -1,5 +1,5 @@
<dataset>
- <file_sources id="2" project_uuid="ABCD" file_uuid="KLMN" data="[null]" line_hashes="[null]" data_hash="321654988"
+ <file_sources id="2" project_uuid="ABCD" file_uuid="KLMN" binary_data="[null]" line_hashes="[null]" data_hash="321654988"
created_at="123456789" updated_at="123456789" src_hash="123456"/>
</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/delete_file_sources_of_disabled_resources.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/delete_file_sources_of_disabled_resources.xml
index fa5e4a7828d..aaae9915d98 100644
--- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/delete_file_sources_of_disabled_resources.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/delete_file_sources_of_disabled_resources.xml
@@ -72,8 +72,8 @@
depth="[null]" scope="PRJ" qualifier="TRK" created_at="1228222680000"
build_date="1228222680000" version="[null]" path="[null]"/>
- <file_sources id="1" project_uuid="ABCD" file_uuid="GHIJ" data="[null]" line_hashes="[null]" data_hash="321654987"
+ <file_sources id="1" project_uuid="ABCD" file_uuid="GHIJ" binary_data="[null]" line_hashes="[null]" data_hash="321654987"
created_at="123456789" updated_at="123456789" src_hash="12345"/>
- <file_sources id="2" project_uuid="ABCD" file_uuid="KLMN" data="[null]" line_hashes="[null]" data_hash="321654988"
+ <file_sources id="2" project_uuid="ABCD" file_uuid="KLMN" binary_data="[null]" line_hashes="[null]" data_hash="321654988"
created_at="123456789" updated_at="123456789" src_hash="123456"/>
</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/disable_resources_without_last_snapshot-result.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/disable_resources_without_last_snapshot-result.xml
index b996557dd58..530dafeedaa 100644
--- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/disable_resources_without_last_snapshot-result.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/disable_resources_without_last_snapshot-result.xml
@@ -68,12 +68,12 @@ What has been changed :
component_uuid="GHIJ"
project_uuid="ABCD"
status="CLOSED"
- issue_close_date="2014-04-09"
+ issue_close_date="1396994400000"
resolution="REMOVED" line="200" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500"
manual_severity="[false]"
message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]"
issue_attributes="[null]" checksum="[null]" author_login="[null]"
- updated_at="1450000000000" issue_creation_date="2013-04-16" issue_update_date="2014-04-09"
+ updated_at="1450000000000" issue_creation_date="1366063200000" issue_update_date="1396994400000"
created_at="1450000000000" tags="[null]"/>
<!-- Open issue on directory -->
@@ -81,12 +81,12 @@ What has been changed :
component_uuid="EFGH"
project_uuid="ABCD"
status="CLOSED"
- issue_close_date="2014-04-09"
+ issue_close_date="1396994400000"
resolution="REMOVED" line="[null]" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500"
manual_severity="[false]"
message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]"
issue_attributes="[null]" checksum="[null]" author_login="[null]"
- updated_at="1450000000000" issue_creation_date="2013-04-16" issue_update_date="2014-04-09"
+ updated_at="1450000000000" issue_creation_date="1366063200000" issue_update_date="1396994400000"
created_at="1450000000000" tags="[null]"/>
<!-- Open issue on project -->
@@ -94,12 +94,12 @@ What has been changed :
component_uuid="ABCD"
project_uuid="ABCD"
status="CLOSED"
- issue_close_date="2014-04-09"
+ issue_close_date="1396994400000"
resolution="REMOVED" line="[null]" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500"
manual_severity="[false]"
message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]"
issue_attributes="[null]" checksum="[null]" author_login="[null]"
- updated_at="1450000000000" issue_creation_date="2013-04-16" issue_update_date="2014-04-09"
+ updated_at="1450000000000" issue_creation_date="1366063200000" issue_update_date="1396994400000"
created_at="1450000000000" tags="[null]"/>
<!-- Resolved issue on file -> not to be updated -->
@@ -107,12 +107,12 @@ What has been changed :
component_uuid="GHIJ"
project_uuid="ABCD"
status="CLOSED"
- issue_close_date="2015-12-08"
+ issue_close_date="1449529200000"
resolution="FIXED" line="200" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500"
manual_severity="[false]"
message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]"
issue_attributes="[null]" checksum="[null]" author_login="[null]"
- updated_at="1450000000000" issue_creation_date="2013-04-16" issue_update_date="2014-04-08"
+ updated_at="1450000000000" issue_creation_date="1366063200000" issue_update_date="1396908000000"
created_at="1450000000000" tags="[null]"/>
</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/disable_resources_without_last_snapshot.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/disable_resources_without_last_snapshot.xml
index ef2dd1725ec..46f8dbc543c 100644
--- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/disable_resources_without_last_snapshot.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/disable_resources_without_last_snapshot.xml
@@ -54,7 +54,7 @@
issue_close_date="[null]"
resolution="[null]" line="200" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500" manual_severity="[false]"
message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]" issue_attributes="[null]" checksum="[null]" author_login="[null]"
- updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16" created_at="1450000000000"/>
+ updated_at="[null]" issue_creation_date="1366063200000" issue_update_date="1366063200000" created_at="1450000000000"/>
<!-- Open issue on directory -->
<issues id="2" kee="ISSUE-2"
@@ -64,7 +64,7 @@
issue_close_date="[null]"
resolution="[null]" line="[null]" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500" manual_severity="[false]"
message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]" issue_attributes="[null]" checksum="[null]" author_login="[null]"
- updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16" created_at="1450000000000"/>
+ updated_at="[null]" issue_creation_date="1366063200000" issue_update_date="1366063200000" created_at="1450000000000"/>
<!-- Open issue on project -->
<issues id="3" kee="ISSUE-3"
@@ -74,16 +74,16 @@
issue_close_date="[null]"
resolution="[null]" line="[null]" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500" manual_severity="[false]"
message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]" issue_attributes="[null]" checksum="[null]" author_login="[null]"
- updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16" created_at="1450000000000"/>
+ updated_at="[null]" issue_creation_date="1366063200000" issue_update_date="1366063200000" created_at="1450000000000"/>
<!-- Resolved issue on file -> not to be updated -->
<issues id="4" kee="ISSUE-4"
component_uuid="GHIJ"
project_uuid="ABCD"
status="CLOSED"
- issue_close_date="2015-12-08"
+ issue_close_date="1449529200000"
resolution="FIXED" line="200" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500" manual_severity="[false]"
message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]" issue_attributes="[null]" checksum="[null]" author_login="[null]"
- updated_at="1450000000000" issue_creation_date="2013-04-16" issue_update_date="2014-04-08" created_at="1450000000000"/>
+ updated_at="1450000000000" issue_creation_date="1366063200000" issue_update_date="1396908000000" created_at="1450000000000"/>
</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/select_purgeable_file_uuids.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/select_purgeable_file_uuids.xml
index cfc39014c9d..5bbb5aa5891 100644
--- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/select_purgeable_file_uuids.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/select_purgeable_file_uuids.xml
@@ -79,8 +79,8 @@
depth="[null]" scope="PRJ" qualifier="TRK" created_at="1228222680000"
build_date="1228222680000" version="[null]" path="[null]"/>
- <file_sources id="1" project_uuid="ABCD" file_uuid="GHIJ" data="[null]" line_hashes="[null]" data_hash="321654987"
+ <file_sources id="1" project_uuid="ABCD" file_uuid="GHIJ" binary_data="[null]" line_hashes="[null]" data_hash="321654987"
created_at="123456789" updated_at="123456789"/>
- <file_sources id="2" project_uuid="ABCD" file_uuid="KLMN" data="[null]" line_hashes="[null]" data_hash="321654988"
+ <file_sources id="2" project_uuid="ABCD" file_uuid="KLMN" binary_data="[null]" line_hashes="[null]" data_hash="321654988"
created_at="123456789" updated_at="123456789"/>
</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteProject.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteProject.xml
index 3d6f4e67009..d50cc3926f5 100644
--- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteProject.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteProject.xml
@@ -29,9 +29,9 @@
action_plan_key="[null]"
created_at="[null]"
updated_at="[null]"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
/>
<issues id="2" kee="ABCDF" component_uuid="A" project_uuid="A" status="CLOSED" resolution="[null]" line="200"
@@ -42,9 +42,9 @@
action_plan_key="[null]"
created_at="[null]"
updated_at="[null]"
- issue_creation_date="2013-04-16"
- issue_update_date="2013-04-16"
- issue_close_date="2013-04-16"
+ issue_creation_date="1366063200000"
+ issue_update_date="1366063200000"
+ issue_close_date="1366063200000"
/>
<issue_changes id="1" kee="[null]" issue_key="ABCDF" created_at="[null]" updated_at="[null]" user_login="admin"
@@ -103,6 +103,6 @@
depth="[null]" scope="FIL" qualifier="FIL" created_at="1228222680000"
build_date="1228222680000"
version="[null]" path="[null]"/>
- <file_sources id="1" project_uuid="A" file_uuid="D" data="[null]" line_hashes="[null]" data_hash="321654987"
+ <file_sources id="1" project_uuid="A" file_uuid="D" binary_data="[null]" line_hashes="[null]" data_hash="321654987"
created_at="123456789" updated_at="123456789"/>
</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/should_delete_all_closed_issues-result.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/should_delete_all_closed_issues-result.xml
index 5f51cd5e54b..142d23dcfe0 100644
--- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/should_delete_all_closed_issues-result.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/should_delete_all_closed_issues-result.xml
@@ -28,20 +28,20 @@
component_uuid="100"
project_uuid="1"
status="CLOSED"
- issue_close_date="2010-01-01"
+ issue_close_date="1262300400000"
resolution="FIXED" line="200" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500" manual_severity="[false]"
message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]" issue_attributes="[null]" checksum="[null]" author_login="[null]"
- updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16" created_at="2013-04-16"/>
+ updated_at="[null]" issue_creation_date="1366063200000" issue_update_date="1366063200000" created_at="2013-04-16"/>
<issue_changes id="1" kee="[null]" issue_key="ISSUE-1" created_at="[null]" updated_at="[null]" user_login="admin" change_type="comment" change_data="abc" issue_change_creation_date="[null]"/>
<issues id="2" kee="ISSUE-2"
component_uuid="1"
project_uuid="1"
status="CLOSED"
- issue_close_date="2010-01-01"
+ issue_close_date="1262300400000"
resolution="FIXED" line="200" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500" manual_severity="[false]"
message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]" issue_attributes="[null]" checksum="[null]" author_login="[null]"
- updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16" created_at="2013-04-16"/>
+ updated_at="[null]" issue_creation_date="1366063200000" issue_update_date="1366063200000" created_at="2013-04-16"/>
<issue_changes id="2" kee="[null]" issue_key="ISSUE-2" created_at="[null]" updated_at="[null]" user_login="admin" change_type="comment" change_data="abc" issue_change_creation_date="[null]"/>
-->
@@ -55,7 +55,7 @@
manual_severity="[false]" tags="[null]"
message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]"
issue_attributes="[null]" checksum="[null]" author_login="[null]"
- updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16"
+ updated_at="[null]" issue_creation_date="1366063200000" issue_update_date="1366063200000"
created_at="1400000000000"/>
<issue_changes id="3" kee="[null]" issue_key="ISSUE-3" created_at="[null]" updated_at="[null]" user_login="admin"
change_type="comment" change_data="abc" issue_change_creation_date="[null]"/>
@@ -70,7 +70,7 @@
manual_severity="[false]" tags="[null]"
message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]"
issue_attributes="[null]" checksum="[null]" author_login="[null]"
- updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16"
+ updated_at="[null]" issue_creation_date="1366063200000" issue_update_date="1366063200000"
created_at="1400000000000"/>
<issue_changes id="4" kee="[null]" issue_key="ISSUE-4" created_at="[null]" updated_at="[null]" user_login="admin"
change_type="comment" change_data="abc" issue_change_creation_date="[null]"/>
@@ -80,10 +80,10 @@
component_uuid="100"
project_uuid="1"
status="CLOSED"
- issue_close_date="2025-01-01"
+ issue_close_date="1735686000000"
resolution="FIXED" line="200" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500" manual_severity="[false]"
message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]" issue_attributes="[null]" checksum="[null]" author_login="[null]"
- updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16" created_at="2013-04-16"/>
+ updated_at="[null]" issue_creation_date="1366063200000" issue_update_date="1366063200000" created_at="2013-04-16"/>
<issue_changes id="5" kee="[null]" issue_key="ISSUE-5" created_at="[null]" updated_at="[null]" user_login="admin" change_type="comment" change_data="abc" issue_change_creation_date="[null]"/>
-->
</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/should_delete_all_closed_issues.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/should_delete_all_closed_issues.xml
index 38c9c3ec360..9fe05024ebd 100644
--- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/should_delete_all_closed_issues.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/should_delete_all_closed_issues.xml
@@ -22,12 +22,12 @@
component_uuid="100"
project_uuid="1"
status="CLOSED"
- issue_close_date="2010-01-01"
+ issue_close_date="1262300400000"
resolution="FIXED" line="200" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500"
manual_severity="[false]"
message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]"
issue_attributes="[null]" checksum="[null]" author_login="[null]"
- updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16"
+ updated_at="[null]" issue_creation_date="1366063200000" issue_update_date="1366063200000"
created_at="1400000000000"/>
<issue_changes id="1" kee="[null]" issue_key="ISSUE-1" created_at="[null]" updated_at="[null]" user_login="admin"
change_type="comment" change_data="abc" issue_change_creation_date="[null]"/>
@@ -36,12 +36,12 @@
component_uuid="1"
project_uuid="1"
status="CLOSED"
- issue_close_date="2010-01-01"
+ issue_close_date="1262300400000"
resolution="FIXED" line="200" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500"
manual_severity="[false]"
message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]"
issue_attributes="[null]" checksum="[null]" author_login="[null]"
- updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16"
+ updated_at="[null]" issue_creation_date="1366063200000" issue_update_date="1366063200000"
created_at="1400000000000"/>
<issue_changes id="2" kee="[null]" issue_key="ISSUE-2" created_at="[null]" updated_at="[null]" user_login="admin"
change_type="comment" change_data="abc" issue_change_creation_date="[null]"/>
@@ -57,7 +57,7 @@
manual_severity="[false]"
message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]"
issue_attributes="[null]" checksum="[null]" author_login="[null]"
- updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16"
+ updated_at="[null]" issue_creation_date="1366063200000" issue_update_date="1366063200000"
created_at="1400000000000"/>
<issue_changes id="3" kee="[null]" issue_key="ISSUE-3" created_at="[null]" updated_at="[null]" user_login="admin"
change_type="comment" change_data="abc" issue_change_creation_date="[null]"/>
@@ -72,7 +72,7 @@
manual_severity="[false]"
message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]"
issue_attributes="[null]" checksum="[null]" author_login="[null]"
- updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16"
+ updated_at="[null]" issue_creation_date="1366063200000" issue_update_date="1366063200000"
created_at="1400000000000"/>
<issue_changes id="4" kee="[null]" issue_key="ISSUE-4" created_at="[null]" updated_at="[null]" user_login="admin"
change_type="comment" change_data="abc" issue_change_creation_date="[null]"/>
@@ -81,12 +81,12 @@
component_uuid="100"
project_uuid="1"
status="CLOSED"
- issue_close_date="2025-01-01"
+ issue_close_date="1735686000000"
resolution="FIXED" line="200" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500"
manual_severity="[false]"
message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]"
issue_attributes="[null]" checksum="[null]" author_login="[null]"
- updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16"
+ updated_at="[null]" issue_creation_date="1366063200000" issue_update_date="1366063200000"
created_at="1400000000000"/>
<issue_changes id="5" kee="[null]" issue_key="ISSUE-5" created_at="[null]" updated_at="[null]" user_login="admin"
change_type="comment" change_data="abc" issue_change_creation_date="[null]"/>
diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/should_delete_old_closed_issues-result.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/should_delete_old_closed_issues-result.xml
index 1095715f65f..1b0bcc3857b 100644
--- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/should_delete_old_closed_issues-result.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/should_delete_old_closed_issues-result.xml
@@ -20,20 +20,20 @@
component_uuid="100"
project_uuid="1"
status="CLOSED"
- issue_close_date="2010-01-01"
+ issue_close_date="1262300400000"
resolution="FIXED" line="200" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500" manual_severity="[false]"
message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]" issue_attributes="[null]" checksum="[null]" author_login="[null]"
- updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16" created_at="2013-04-16"/>
+ updated_at="[null]" issue_creation_date="1366063200000" issue_update_date="1366063200000" created_at="2013-04-16"/>
<issue_changes id="1" kee="[null]" issue_key="ISSUE-1" created_at="[null]" updated_at="[null]" user_login="admin" change_type="comment" change_data="abc" issue_change_creation_date="[null]"/>
<issues id="2" kee="ISSUE-2"
component_uuid="1"
project_uuid="1"
status="CLOSED"
- issue_close_date="2010-01-01"
+ issue_close_date="1262300400000"
resolution="FIXED" line="200" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500" manual_severity="[false]"
message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]" issue_attributes="[null]" checksum="[null]" author_login="[null]"
- updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16" created_at="2013-04-16"/>
+ updated_at="[null]" issue_creation_date="1366063200000" issue_update_date="1366063200000" created_at="2013-04-16"/>
<issue_changes id="2" kee="[null]" issue_key="ISSUE-2" created_at="[null]" updated_at="[null]" user_login="admin" change_type="comment" change_data="abc" issue_change_creation_date="[null]"/>
-->
@@ -45,7 +45,7 @@
issue_close_date="[null]"
resolution="[null]" line="200" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500" manual_severity="[false]" tags="[null]"
message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]" issue_attributes="[null]" checksum="[null]" author_login="[null]"
- updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16" created_at="1400000000000"/>
+ updated_at="[null]" issue_creation_date="1366063200000" issue_update_date="1366063200000" created_at="1400000000000"/>
<issue_changes id="3" kee="[null]" issue_key="ISSUE-3" created_at="[null]" updated_at="[null]" user_login="admin" change_type="comment" change_data="abc" issue_change_creation_date="[null]"/>
<!-- recent open and closed issues -> do not purge -->
@@ -56,17 +56,17 @@
issue_close_date="[null]"
resolution="[null]" line="200" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500" manual_severity="[false]" tags="[null]"
message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]" issue_attributes="[null]" checksum="[null]" author_login="[null]"
- updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16" created_at="1400000000000"/>
+ updated_at="[null]" issue_creation_date="1366063200000" issue_update_date="1366063200000" created_at="1400000000000"/>
<issue_changes id="4" kee="[null]" issue_key="ISSUE-4" created_at="[null]" updated_at="[null]" user_login="admin" change_type="comment" change_data="abc" issue_change_creation_date="[null]"/>
<issues id="5" kee="ISSUE-5"
component_uuid="100"
project_uuid="1"
status="CLOSED"
- issue_close_date="2025-01-01"
+ issue_close_date="1735686000000"
resolution="FIXED" line="200" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500" manual_severity="[false]" tags="[null]"
message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]" issue_attributes="[null]" checksum="[null]" author_login="[null]"
- updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16" created_at="1400000000000"/>
+ updated_at="[null]" issue_creation_date="1366063200000" issue_update_date="1366063200000" created_at="1400000000000"/>
<issue_changes id="5" kee="[null]" issue_key="ISSUE-5" created_at="[null]" updated_at="[null]" user_login="admin" change_type="comment" change_data="abc" issue_change_creation_date="[null]"/>
</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/should_delete_old_closed_issues.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/should_delete_old_closed_issues.xml
index eb9fc8960c5..95d56051843 100644
--- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/should_delete_old_closed_issues.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/should_delete_old_closed_issues.xml
@@ -21,12 +21,12 @@
component_uuid="100"
project_uuid="1"
status="CLOSED"
- issue_close_date="2010-01-01"
+ issue_close_date="1262300400000"
resolution="FIXED" line="200" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500"
manual_severity="[false]"
message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]"
issue_attributes="[null]" checksum="[null]" author_login="[null]"
- updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16"
+ updated_at="[null]" issue_creation_date="1366063200000" issue_update_date="1366063200000"
created_at="1400000000000"/>
<issue_changes id="1" kee="[null]" issue_key="ISSUE-1" created_at="[null]" updated_at="[null]" user_login="admin"
change_type="comment" change_data="abc" issue_change_creation_date="[null]"/>
@@ -35,12 +35,12 @@
component_uuid="1"
project_uuid="1"
status="CLOSED"
- issue_close_date="2010-01-01"
+ issue_close_date="1262300400000"
resolution="FIXED" line="200" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500"
manual_severity="[false]"
message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]"
issue_attributes="[null]" checksum="[null]" author_login="[null]"
- updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16"
+ updated_at="[null]" issue_creation_date="1366063200000" issue_update_date="1366063200000"
created_at="1400000000000"/>
<issue_changes id="2" kee="[null]" issue_key="ISSUE-2" created_at="[null]" updated_at="[null]" user_login="admin"
change_type="comment" change_data="abc" issue_change_creation_date="[null]"/>
@@ -56,7 +56,7 @@
manual_severity="[false]"
message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]"
issue_attributes="[null]" checksum="[null]" author_login="[null]"
- updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16"
+ updated_at="[null]" issue_creation_date="1366063200000" issue_update_date="1366063200000"
created_at="1400000000000"/>
<issue_changes id="3" kee="[null]" issue_key="ISSUE-3" created_at="[null]" updated_at="[null]" user_login="admin"
change_type="comment" change_data="abc" issue_change_creation_date="[null]"/>
@@ -71,7 +71,7 @@
manual_severity="[false]"
message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]"
issue_attributes="[null]" checksum="[null]" author_login="[null]"
- updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16"
+ updated_at="[null]" issue_creation_date="1366063200000" issue_update_date="1366063200000"
created_at="1400000000000"/>
<issue_changes id="4" kee="[null]" issue_key="ISSUE-4" created_at="[null]" updated_at="[null]" user_login="admin"
change_type="comment" change_data="abc" issue_change_creation_date="[null]"/>
@@ -80,12 +80,12 @@
component_uuid="100"
project_uuid="1"
status="CLOSED"
- issue_close_date="2025-01-01"
+ issue_close_date="1735686000000"
resolution="FIXED" line="200" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500"
manual_severity="[false]"
message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]"
issue_attributes="[null]" checksum="[null]" author_login="[null]"
- updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16"
+ updated_at="[null]" issue_creation_date="1366063200000" issue_update_date="1366063200000"
created_at="1400000000000"/>
<issue_changes id="5" kee="[null]" issue_key="ISSUE-5" created_at="[null]" updated_at="[null]" user_login="admin"
change_type="comment" change_data="abc" issue_change_creation_date="[null]"/>
diff --git a/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/insert-result.xml b/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/insert-result.xml
index f43f9f06564..74bca5ec788 100644
--- a/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/insert-result.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/insert-result.xml
@@ -1,16 +1,17 @@
<dataset>
- <file_sources id="101" project_uuid="abcd" file_uuid="ab12"
- data="aef12a,alice,2014-04-25T12:34:56+0100,,class Foo" data_hash="hash"
- line_hashes="truc"
- src_hash="12345"
- created_at="1414597442000" updated_at="1414683842000" />
+ <file_sources id="101" project_uuid="PRJ_UUID" file_uuid="FILE1_UUID"
+ binary_data="abcde" data_hash="hash"
+ line_hashes="ABC\nDEF\nGHI"
+ src_hash="FILE_HASH"
+ created_at="1500000000000" updated_at="1500000000000" />
- <file_sources id="102" project_uuid="prj" file_uuid="file"
- data="bla bla" data_hash="hash2"
- line_hashes="foo&#10;bar"
- src_hash="hache"
- created_at="1414770242000" updated_at="1414770242000" />
+ <file_sources id="102" project_uuid="PRJ_UUID" file_uuid="FILE2_UUID"
+ binary_data="[ignore]"
+ data_hash="FILE2_DATA_HASH"
+ line_hashes="LINE1_HASH\nLINE2_HASH"
+ src_hash="FILE2_HASH"
+ created_at="1500000000000" updated_at="1500000000001" />
</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/shared.xml b/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/shared.xml
index fbfa94a6ddd..79a340f841d 100644
--- a/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/shared.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/shared.xml
@@ -1,9 +1,9 @@
<dataset>
- <file_sources id="101" project_uuid="abcd" file_uuid="ab12"
- data="aef12a,alice,2014-04-25T12:34:56+0100,,class Foo" data_hash="hash"
- line_hashes="truc"
- src_hash="12345"
- created_at="1414597442000" updated_at="1414683842000" />
+ <file_sources id="101" project_uuid="PRJ_UUID" file_uuid="FILE1_UUID"
+ binary_data="abcde" data_hash="hash"
+ line_hashes="ABC\nDEF\nGHI"
+ src_hash="FILE_HASH"
+ created_at="1500000000000" updated_at="1500000000000" />
</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/update-result.xml b/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/update-result.xml
index 64ff997152f..40cbfa91a43 100644
--- a/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/update-result.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/update-result.xml
@@ -1,10 +1,11 @@
<dataset>
- <file_sources id="101" project_uuid="abcd" file_uuid="ab12"
- data="updated data" data_hash="hash2"
- line_hashes="foo2&#10;bar2"
- src_hash="123456"
- created_at="1414597442000" updated_at="1414770242000" />
+ <file_sources id="101" project_uuid="PRJ_UUID" file_uuid="FILE1_UUID"
+ binary_data="[ignore]"
+ data_hash="NEW_DATA_HASH"
+ line_hashes="NEW_LINE_HASHES"
+ src_hash="NEW_FILE_HASH"
+ created_at="1500000000000" updated_at="1500000000002" />
</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/user/AuthorDaoTest/add_missing_module_uuid_path-result.xml b/sonar-core/src/test/resources/org/sonar/core/user/AuthorDaoTest/add_missing_module_uuid_path-result.xml
index b8737c88118..742ae70faad 100644
--- a/sonar-core/src/test/resources/org/sonar/core/user/AuthorDaoTest/add_missing_module_uuid_path-result.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/user/AuthorDaoTest/add_missing_module_uuid_path-result.xml
@@ -1,7 +1,7 @@
<dataset>
- <projects id="1" name="developer@company.net" qualifier="DEV" uuid="ABCD" project_uuid="ABCD" module_uuid="[null]" module_uuid_path="."/>
+ <projects id="1" name="developer@company.net" qualifier="DEV" uuid="ABCD" project_uuid="ABCD" module_uuid="[null]" module_uuid_path=".ABCD."/>
<authors id="1" person_id="1" login="developer@company.net"/>
- <projects id="2" name="developer2@company.net" qualifier="DEV" uuid="BCDE" project_uuid="BCDE" module_uuid="[null]" module_uuid_path="."/>
+ <projects id="2" name="developer2@company.net" qualifier="DEV" uuid="BCDE" project_uuid="BCDE" module_uuid="[null]" module_uuid_path=".BCDE."/>
<authors id="2" person_id="2" login="developer2@company.net"/>
</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/user/AuthorizationDaoTest/user_should_be_authorized.xml b/sonar-core/src/test/resources/org/sonar/core/user/AuthorizationDaoTest/user_should_be_authorized.xml
index b6371a7e0b1..3771e09738d 100644
--- a/sonar-core/src/test/resources/org/sonar/core/user/AuthorizationDaoTest/user_should_be_authorized.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/user/AuthorizationDaoTest/user_should_be_authorized.xml
@@ -6,9 +6,6 @@
<groups_users user_id="100" group_id="200"/>
<group_roles id="1" group_id="200" resource_id="999" role="user"/>
- <projects id="301" kee="pj-w-snapshot:package" root_id="300" uuid="ABCD" module_uuid="DEFG"/>
- <projects id="302" kee="pj-w-snapshot:file" root_id="300" uuid="BCDE" module_uuid="DEFG"/>
- <projects id="303" kee="pj-w-snapshot:other" root_id="300" uuid="CDEF" module_uuid="DEFG"/>
<projects id="300" kee="pj-w-snapshot" uuid="DEFG" module_uuid="[null]"/>
<projects id="400" kee="pj-wo-snapshot" uuid="EFGH" module_uuid="[null]"/>
</dataset>