]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5329 - Rename Log package to Activity
authorStephane Gamard <stephane.gamard@searchbox.com>
Mon, 16 Jun 2014 11:11:32 +0000 (13:11 +0200)
committerStephane Gamard <stephane.gamard@searchbox.com>
Mon, 16 Jun 2014 11:22:02 +0000 (13:22 +0200)
32 files changed:
sonar-core/src/main/java/org/sonar/core/activity/Activity.java [new file with mode: 0644]
sonar-core/src/main/java/org/sonar/core/activity/ActivityLog.java [new file with mode: 0644]
sonar-core/src/main/java/org/sonar/core/activity/db/ActivityDto.java [new file with mode: 0644]
sonar-core/src/main/java/org/sonar/core/activity/db/ActivityKey.java [new file with mode: 0644]
sonar-core/src/main/java/org/sonar/core/activity/db/ActivityMapper.java [new file with mode: 0644]
sonar-core/src/main/java/org/sonar/core/log/Log.java [deleted file]
sonar-core/src/main/java/org/sonar/core/log/Loggable.java [deleted file]
sonar-core/src/main/java/org/sonar/core/log/db/LogDto.java [deleted file]
sonar-core/src/main/java/org/sonar/core/log/db/LogKey.java [deleted file]
sonar-core/src/main/java/org/sonar/core/log/db/LogMapper.java [deleted file]
sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java
sonar-core/src/main/resources/org/sonar/core/log/db/LogMapper.xml [deleted file]
sonar-core/src/test/java/org/sonar/core/profiling/ProfilingActivityFactoryTest.java [new file with mode: 0644]
sonar-core/src/test/java/org/sonar/core/profiling/ProfilingLogFactoryTest.java [deleted file]
sonar-server/src/main/java/org/sonar/server/db/DbClient.java
sonar-server/src/main/java/org/sonar/server/log/LogService.java [deleted file]
sonar-server/src/main/java/org/sonar/server/log/db/LogDao.java [deleted file]
sonar-server/src/main/java/org/sonar/server/log/index/LogDoc.java [deleted file]
sonar-server/src/main/java/org/sonar/server/log/index/LogIndex.java [deleted file]
sonar-server/src/main/java/org/sonar/server/log/index/LogNormalizer.java [deleted file]
sonar-server/src/main/java/org/sonar/server/log/index/LogQuery.java [deleted file]
sonar-server/src/main/java/org/sonar/server/log/ws/LogMapping.java [deleted file]
sonar-server/src/main/java/org/sonar/server/log/ws/LogsWebService.java [deleted file]
sonar-server/src/main/java/org/sonar/server/log/ws/SearchAction.java [deleted file]
sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java
sonar-server/src/main/java/org/sonar/server/qualityprofile/ActiveRuleChange.java
sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java
sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java
sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleIndex.java
sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleChangeMediumTest.java
sonar-server/src/test/java/org/sonar/server/startup/ActivityServerIdTest.java [new file with mode: 0644]
sonar-server/src/test/java/org/sonar/server/startup/LogServerIdTest.java [deleted file]

diff --git a/sonar-core/src/main/java/org/sonar/core/activity/Activity.java b/sonar-core/src/main/java/org/sonar/core/activity/Activity.java
new file mode 100644 (file)
index 0000000..b80fdd1
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * 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.activity;
+
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * @since 4.4
+ */
+public interface Activity {
+
+  public static enum Type {
+    NONE, ACTIVE_RULE, SERVER
+  }
+
+  Date time();
+
+  String author();
+
+  Integer executionTime();
+
+  Map<String, String> details();
+
+  String message();
+
+}
diff --git a/sonar-core/src/main/java/org/sonar/core/activity/ActivityLog.java b/sonar-core/src/main/java/org/sonar/core/activity/ActivityLog.java
new file mode 100644 (file)
index 0000000..f55aee1
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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.activity;
+
+import java.util.Map;
+
+/**
+ * @since 4.4
+ */
+public interface ActivityLog {
+
+  Map<String, String> getDetails();
+
+  int getExecutionTime();
+
+}
diff --git a/sonar-core/src/main/java/org/sonar/core/activity/db/ActivityDto.java b/sonar-core/src/main/java/org/sonar/core/activity/db/ActivityDto.java
new file mode 100644 (file)
index 0000000..3d7d1ce
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * 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.activity.db;
+
+import org.apache.commons.lang.builder.ReflectionToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+import org.sonar.api.utils.KeyValueFormat;
+import org.sonar.core.activity.Activity;
+import org.sonar.core.activity.ActivityLog;
+import org.sonar.core.persistence.Dto;
+
+/**
+ * @since 4.4
+ */
+public final class ActivityDto extends Dto<ActivityKey> {
+
+  private String message;
+  private Activity.Type type;
+  private String author;
+
+  private Integer executionTime;
+
+  private String data;
+
+  protected ActivityDto() {
+  }
+
+  @Override
+  public ActivityKey getKey() {
+    return ActivityKey.of(this.getCreatedAt(), type, author);
+  }
+
+  @Override
+  public String toString() {
+    return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
+  }
+
+  public Activity.Type getType() {
+    return type;
+  }
+
+  public ActivityDto setType(Activity.Type type) {
+    this.type = type;
+    return this;
+  }
+
+  public String getAuthor() {
+    return author;
+  }
+
+  public ActivityDto setAuthor(String author) {
+    this.author = author;
+    return this;
+  }
+
+  public Integer getExecutionTime() {
+    return executionTime;
+  }
+
+  public ActivityDto setExecutionTime(Integer executionTime) {
+    this.executionTime = executionTime;
+    return this;
+  }
+
+  public String getData() {
+    return data;
+  }
+
+  public ActivityDto setData(String data) {
+    this.data = data;
+    return this;
+  }
+
+  public String getMessage() {
+    return message;
+  }
+
+  public ActivityDto setMessage(String message) {
+    this.message = message;
+    return this;
+  }
+
+  public static ActivityDto createFor(String message) {
+    return new ActivityDto()
+      .setMessage(message);
+  }
+
+  public static ActivityDto createFor(ActivityLog activityLog) {
+    return new ActivityDto()
+      .setData(KeyValueFormat.format(activityLog.getDetails()))
+      .setExecutionTime(activityLog.getExecutionTime());
+  }
+}
diff --git a/sonar-core/src/main/java/org/sonar/core/activity/db/ActivityKey.java b/sonar-core/src/main/java/org/sonar/core/activity/db/ActivityKey.java
new file mode 100644 (file)
index 0000000..7031b1f
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * 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.activity.db;
+
+import com.google.common.base.Preconditions;
+import org.sonar.core.activity.Activity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @since 4.4
+ */
+public class ActivityKey implements Serializable {
+
+  private Date createdAt;
+  private Activity.Type type;
+  private String author;
+
+  public ActivityKey(Date createdAt, Activity.Type type, String author) {
+    this.createdAt = createdAt;
+    this.type = type;
+    this.author = author;
+  }
+
+  /**
+   * Create a key. Parameters are NOT null.
+   */
+  public static ActivityKey of(Date createdAt, Activity.Type type, String author) {
+    Preconditions.checkArgument(createdAt != null, "Time must be set");
+    Preconditions.checkArgument(type != null, "Type must be set");
+    Preconditions.checkArgument(author != null, "Author must be set");
+    return new ActivityKey(createdAt, type, author);
+  }
+
+  /**
+   * Create a key from a string representation (see {@link #toString()}. An {@link IllegalArgumentException} is raised
+   * if the format is not valid.
+   */
+  public static ActivityKey parse(String s) {
+    String[] split = s.split(":");
+    Preconditions.checkArgument(split.length == 3, "Invalid log key: " + s);
+    return ActivityKey.of(new Date(Long.getLong(split[0])),
+      Activity.Type.valueOf(split[1]), split[2]);
+  }
+
+  public Date getCreatedAt() {
+    return createdAt;
+  }
+
+  public void setCreatedAt(Date createdAt) {
+    this.createdAt = createdAt;
+  }
+
+  public String getAuthor() {
+    return author;
+  }
+
+  public ActivityKey setAuthor(String author) {
+    this.author = author;
+    return this;
+  }
+
+  public Activity.Type getType() {
+    return type;
+  }
+
+  public ActivityKey setType(Activity.Type type) {
+    this.type = type;
+    return this;
+  }
+
+  @Override
+  public String toString() {
+    return this.createdAt.getTime() +
+      ":" + this.type +
+      ":" + this.getAuthor();
+  }
+}
diff --git a/sonar-core/src/main/java/org/sonar/core/activity/db/ActivityMapper.java b/sonar-core/src/main/java/org/sonar/core/activity/db/ActivityMapper.java
new file mode 100644 (file)
index 0000000..dd47fc8
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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.activity.db;
+
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * @since 4.4
+ */
+public interface ActivityMapper {
+
+  void insert(ActivityDto rule);
+
+  ActivityDto selectByKey(@Param("key") ActivityKey key);
+
+  List<ActivityDto> selectAll();
+}
diff --git a/sonar-core/src/main/java/org/sonar/core/log/Log.java b/sonar-core/src/main/java/org/sonar/core/log/Log.java
deleted file mode 100644 (file)
index bac7b76..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.log;
-
-import java.util.Date;
-import java.util.Map;
-
-/**
- * @since 4.4
- */
-public interface Log {
-
-  public static enum Type {
-    NONE, ACTIVE_RULE, SERVER
-  }
-
-  Date time();
-
-  String author();
-
-  Integer executionTime();
-
-  Map<String, String> details();
-
-  String message();
-
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/log/Loggable.java b/sonar-core/src/main/java/org/sonar/core/log/Loggable.java
deleted file mode 100644 (file)
index e8ad9e0..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.log;
-
-import java.util.Map;
-
-/**
- * @since 4.4
- */
-public interface Loggable {
-
-  Map<String, String> getDetails();
-
-  int getExecutionTime();
-
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/log/db/LogDto.java b/sonar-core/src/main/java/org/sonar/core/log/db/LogDto.java
deleted file mode 100644 (file)
index 5ed5fa3..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * 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.log.db;
-
-import org.apache.commons.lang.builder.ReflectionToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-import org.sonar.api.utils.KeyValueFormat;
-import org.sonar.core.log.Log;
-import org.sonar.core.log.Loggable;
-import org.sonar.core.persistence.Dto;
-
-/**
- * @since 4.4
- */
-public final class LogDto extends Dto<LogKey> {
-
-  private String message;
-  private Log.Type type;
-  private String author;
-
-  private Integer executionTime;
-
-  private String data;
-
-  protected LogDto(){
-  }
-
-  @Override
-  public LogKey getKey() {
-    return LogKey.of(this.getCreatedAt(), type, author);
-  }
-
-  @Override
-  public String toString() {
-    return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
-  }
-
-  public Log.Type getType() {
-    return type;
-  }
-
-  public LogDto setType(Log.Type type) {
-    this.type = type;
-    return this;
-  }
-
-  public String getAuthor() {
-    return author;
-  }
-
-  public LogDto setAuthor(String author) {
-    this.author = author;
-    return this;
-  }
-
-  public Integer getExecutionTime() {
-    return executionTime;
-  }
-
-  public LogDto setExecutionTime(Integer executionTime) {
-    this.executionTime = executionTime;
-    return this;
-  }
-
-  public String getData() {
-    return data;
-  }
-
-  public LogDto setData(String data) {
-    this.data = data;
-    return this;
-  }
-
-  public String getMessage() {
-    return message;
-  }
-
-  public LogDto setMessage(String message) {
-    this.message = message;
-    return this;
-  }
-
-  public static LogDto createFor(String message) {
-    return new LogDto()
-      .setMessage(message);
-  }
-
-  public static LogDto createFor(Loggable loggable) {
-    return new LogDto()
-      .setData(KeyValueFormat.format(loggable.getDetails()))
-      .setExecutionTime(loggable.getExecutionTime());
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/log/db/LogKey.java b/sonar-core/src/main/java/org/sonar/core/log/db/LogKey.java
deleted file mode 100644 (file)
index 3077ce3..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * 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.log.db;
-
-import com.google.common.base.Preconditions;
-import org.sonar.core.log.Log;
-
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * @since 4.4
- */
-public class LogKey implements Serializable {
-
-  private Date createdAt;
-  private Log.Type type;
-  private String author;
-
-  public LogKey(Date createdAt, Log.Type type, String author) {
-    this.createdAt = createdAt;
-    this.type = type;
-    this.author = author;
-  }
-
-  /**
-   * Create a key. Parameters are NOT null.
-   */
-  public static LogKey of(Date createdAt, Log.Type type, String author) {
-    Preconditions.checkArgument(createdAt != null, "Time must be set");
-    Preconditions.checkArgument(type != null, "Type must be set");
-    Preconditions.checkArgument(author != null, "Author must be set");
-    return new LogKey(createdAt, type, author);
-  }
-
-  /**
-   * Create a key from a string representation (see {@link #toString()}. An {@link IllegalArgumentException} is raised
-   * if the format is not valid.
-   */
-  public static LogKey parse(String s) {
-    String[] split = s.split(":");
-    Preconditions.checkArgument(split.length == 3, "Invalid log key: " + s);
-    return LogKey.of(new Date(Long.getLong(split[0])),
-      Log.Type.valueOf(split[1]), split[2]);
-  }
-
-  public Date getCreatedAt() {
-    return createdAt;
-  }
-
-  public void setCreatedAt(Date createdAt) {
-    this.createdAt = createdAt;
-  }
-
-  public String getAuthor() {
-    return author;
-  }
-
-  public LogKey setAuthor(String author) {
-    this.author = author;
-    return this;
-  }
-
-  public Log.Type getType() {
-    return type;
-  }
-
-  public LogKey setType(Log.Type type) {
-    this.type = type;
-    return this;
-  }
-
-  @Override
-  public String toString() {
-    return this.createdAt.getTime() +
-      ":" + this.type +
-      ":" + this.getAuthor();
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/log/db/LogMapper.java b/sonar-core/src/main/java/org/sonar/core/log/db/LogMapper.java
deleted file mode 100644 (file)
index 5029cd5..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.log.db;
-
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-
-/**
- * @since 4.4
- */
-public interface LogMapper {
-
-  void insert(LogDto rule);
-
-  LogDto selectByKey(@Param("key") LogKey key);
-
-  List<LogDto> selectAll();
-}
index dc840a99b509233c5c76d632dd67b033574ddeb2..154fbac7bd8d96fc28836ccc98b0913e49dd587c 100644 (file)
@@ -24,18 +24,31 @@ 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.*;
+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.transaction.jdbc.JdbcTransactionFactory;
 import org.apache.ibatis.type.JdbcType;
 import org.slf4j.LoggerFactory;
 import org.sonar.api.BatchComponent;
 import org.sonar.api.ServerComponent;
 import org.sonar.api.database.model.MeasureModel;
+import org.sonar.core.activity.db.ActivityDto;
+import org.sonar.core.activity.db.ActivityMapper;
 import org.sonar.core.cluster.WorkQueue;
 import org.sonar.core.component.ComponentDto;
 import org.sonar.core.component.db.ComponentMapper;
 import org.sonar.core.config.Logback;
-import org.sonar.core.dashboard.*;
+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.dependency.DependencyDto;
 import org.sonar.core.dependency.DependencyMapper;
 import org.sonar.core.dependency.ResourceSnapshotDto;
@@ -44,23 +57,52 @@ 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.*;
-import org.sonar.core.log.db.LogDto;
-import org.sonar.core.log.db.LogMapper;
+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.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.issue.db.IssueStatsMapper;
 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.notification.db.NotificationQueueDto;
 import org.sonar.core.notification.db.NotificationQueueMapper;
-import org.sonar.core.permission.*;
+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.properties.PropertiesMapper;
 import org.sonar.core.properties.PropertyDto;
 import org.sonar.core.purge.PurgeMapper;
 import org.sonar.core.purge.PurgeableSnapshotDto;
-import org.sonar.core.qualitygate.db.*;
-import org.sonar.core.qualityprofile.db.*;
-import org.sonar.core.resource.*;
+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.resource.SnapshotDto;
 import org.sonar.core.rule.RuleDto;
 import org.sonar.core.rule.RuleMapper;
 import org.sonar.core.rule.RuleParamDto;
@@ -72,7 +114,16 @@ 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.*;
+import org.sonar.core.user.AuthorDto;
+import org.sonar.core.user.AuthorMapper;
+import org.sonar.core.user.GroupDto;
+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.UserMapper;
+import org.sonar.core.user.UserRoleDto;
 
 import java.io.InputStream;
 
@@ -152,7 +203,7 @@ public class MyBatis implements BatchComponent, ServerComponent {
     loadAlias(conf, "ActiveRule", ActiveRuleDto.class);
     loadAlias(conf, "ActiveRuleParam", ActiveRuleParamDto.class);
     loadAlias(conf, "RequirementMigration", RequirementMigrationDto.class);
-    loadAlias(conf, "Log", LogDto.class);
+    loadAlias(conf, "Log", ActivityDto.class);
 
     // AuthorizationMapper has to be loaded before IssueMapper because this last one used it
     loadMapper(conf, "org.sonar.core.user.AuthorizationMapper");
@@ -160,7 +211,7 @@ public class MyBatis implements BatchComponent, ServerComponent {
     loadMapper(conf, ResourceMapper.class);
 
     loadMapper(conf, "org.sonar.core.permission.PermissionMapper");
-    Class<?>[] mappers = {LogMapper.class, ActiveDashboardMapper.class, AuthorMapper.class, DashboardMapper.class,
+    Class<?>[] mappers = {ActivityMapper.class, ActiveDashboardMapper.class, AuthorMapper.class, DashboardMapper.class,
       DependencyMapper.class, DuplicationMapper.class, GraphDtoMapper.class,
       IssueMapper.class, IssueStatsMapper.class, IssueChangeMapper.class, IssueFilterMapper.class, IssueFilterFavouriteMapper.class,
       LoadedTemplateMapper.class, MeasureFilterMapper.class, PermissionTemplateMapper.class, PropertiesMapper.class, PurgeMapper.class,
diff --git a/sonar-core/src/main/resources/org/sonar/core/log/db/LogMapper.xml b/sonar-core/src/main/resources/org/sonar/core/log/db/LogMapper.xml
deleted file mode 100644 (file)
index a2e7db6..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-<?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.log.db.LogMapper">
-
-  <insert id="insert" parameterType="Log" useGeneratedKeys="false" lang="raw">
-    insert into logs
-    (created_at, log_type,execution_time_field,user_login,data_field, log_message)
-    values (#{createdAt}, #{type}, #{executionTime}, #{author}, #{data}, #{message})
-  </insert>
-
-  <select id="selectByKey" parameterType="map" resultType="Log" lang="raw">
-    SELECT
-    l.created_at as "createdAt",
-    l.log_type as "type",
-    l.execution_time_field as "executionTime",
-    l.user_login as "author",
-    l.data_field as "data",
-    l.log_message as "message"
-    FROM logs l
-    WHERE l.created_at=#{key.createdAt}
-    AND l.user_login=#{key.author}
-    AND l.log_type=#{key.type}
-  </select>
-
-  <select id="selectAll" parameterType="map" resultType="Log" lang="raw">
-    SELECT
-    l.created_at as "createdAt",
-    l.log_type as "type",
-    l.execution_time_field as "executionTime",
-    l.user_login as "author",
-    l.data_field as "data",
-    l.log_message as "message"
-    FROM logs l
-  </select>
-</mapper>
-
diff --git a/sonar-core/src/test/java/org/sonar/core/profiling/ProfilingActivityFactoryTest.java b/sonar-core/src/test/java/org/sonar/core/profiling/ProfilingActivityFactoryTest.java
new file mode 100644 (file)
index 0000000..32ff4c4
--- /dev/null
@@ -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.profiling;
+
+import org.junit.Test;
+
+public class ProfilingActivityFactoryTest {
+
+  @Test
+  public void just_for_coverage() throws Exception {
+    new ProfilingLogFactory().getLogger("domain");
+  }
+}
diff --git a/sonar-core/src/test/java/org/sonar/core/profiling/ProfilingLogFactoryTest.java b/sonar-core/src/test/java/org/sonar/core/profiling/ProfilingLogFactoryTest.java
deleted file mode 100644 (file)
index be2ad98..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.profiling;
-
-import org.junit.Test;
-
-public class ProfilingLogFactoryTest {
-
-  @Test
-  public void just_for_coverage() throws Exception {
-    new ProfilingLogFactory().getLogger("domain");
-  }
-}
index 2d82e59078010021ac9a9ee159d7b344abd79601..27762a25cf899daa990fb0fa2cbbba44c95106d0 100644 (file)
@@ -30,8 +30,8 @@ import org.sonar.core.qualityprofile.db.QualityProfileDao;
 import org.sonar.core.resource.ResourceDao;
 import org.sonar.core.technicaldebt.db.CharacteristicDao;
 import org.sonar.core.template.LoadedTemplateDao;
+import org.sonar.server.activity.db.ActivityDao;
 import org.sonar.server.component.persistence.ComponentDao;
-import org.sonar.server.log.db.LogDao;
 import org.sonar.server.measure.persistence.MeasureDao;
 import org.sonar.server.qualityprofile.db.ActiveRuleDao;
 import org.sonar.server.rule.db.RuleDao;
@@ -54,7 +54,7 @@ public class DbClient implements ServerComponent {
   private final ComponentDao componentDao;
   private final ResourceDao resourceDao;
   private final MeasureDao measureDao;
-  private final LogDao logDao;
+  private final ActivityDao activityDao;
 
   public DbClient(Database db, MyBatis myBatis, DaoComponent... daoComponents) {
     this.db = db;
@@ -73,7 +73,7 @@ public class DbClient implements ServerComponent {
     componentDao = getDao(map, ComponentDao.class);
     resourceDao = getDao(map, ResourceDao.class);
     measureDao = getDao(map, MeasureDao.class);
-    logDao = getDao(map, LogDao.class);
+    activityDao = getDao(map, ActivityDao.class);
   }
 
   public Database database() {
@@ -120,8 +120,8 @@ public class DbClient implements ServerComponent {
     return measureDao;
   }
 
-  public LogDao logDao() {
-    return logDao;
+  public ActivityDao activityDao() {
+    return activityDao;
   }
 
   private <K> K getDao(Map<Class, DaoComponent> map, Class<K> clazz) {
diff --git a/sonar-server/src/main/java/org/sonar/server/log/LogService.java b/sonar-server/src/main/java/org/sonar/server/log/LogService.java
deleted file mode 100644 (file)
index 994ebb2..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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.server.log;
-
-import org.sonar.core.log.Log;
-import org.sonar.core.log.Loggable;
-import org.sonar.core.log.db.LogDto;
-import org.sonar.core.persistence.DbSession;
-import org.sonar.server.db.DbClient;
-import org.sonar.server.log.index.LogIndex;
-import org.sonar.server.log.index.LogQuery;
-import org.sonar.server.search.IndexClient;
-import org.sonar.server.search.QueryOptions;
-import org.sonar.server.search.Result;
-import org.sonar.server.user.UserSession;
-
-import java.util.List;
-
-/**
- * Log service is used to log Activity classes which represents an event to DB and Index.
- *
- * @see org.sonar.core.log.Loggable
- * @since 4.4
- */
-public class LogService {
-
-  private final DbClient dbClient;
-  private final IndexClient indexClient;
-
-  public LogService(DbClient dbClient, IndexClient indexClient) {
-    this.dbClient = dbClient;
-    this.indexClient = indexClient;
-  }
-
-  private String getAuthor() {
-    return (UserSession.get().login() != null) ? UserSession.get().login() : "UNKNOWN";
-  }
-
-  private void save(DbSession session, LogDto log) {
-    dbClient.logDao().insert(session,
-      log.setAuthor(getAuthor()));
-  }
-
-  public void write(DbSession session, Log.Type type, String message) {
-    this.write(session, type, message, null);
-  }
-
-  public void write(DbSession session, Log.Type type, String message, Integer time) {
-    this.save(session, LogDto.createFor(message)
-      .setType(type)
-      .setExecutionTime(time));
-  }
-
-  public <L extends Loggable> void write(DbSession session, Log.Type type, List<L> logs) {
-    for (Loggable log : logs) {
-      this.write(session, type, log);
-    }
-  }
-
-  public <L extends Loggable> void write(DbSession session, Log.Type type, L log) {
-    this.save(session, LogDto.createFor(log)
-      .setType(type));
-  }
-
-  public LogQuery newLogQuery() {
-    return new LogQuery();
-  }
-
-  public Result<Log> search(LogQuery query, QueryOptions options) {
-    return indexClient.get(LogIndex.class).search(query, options);
-  }
-}
diff --git a/sonar-server/src/main/java/org/sonar/server/log/db/LogDao.java b/sonar-server/src/main/java/org/sonar/server/log/db/LogDao.java
deleted file mode 100644 (file)
index fc7729a..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.server.log.db;
-
-import com.google.common.annotations.VisibleForTesting;
-import org.sonar.api.utils.System2;
-import org.sonar.core.log.db.LogDto;
-import org.sonar.core.log.db.LogKey;
-import org.sonar.core.log.db.LogMapper;
-import org.sonar.core.persistence.DbSession;
-import org.sonar.server.db.BaseDao;
-import org.sonar.server.search.IndexDefinition;
-
-import java.util.List;
-
-/**
- * @since 4.4
- */
-public class LogDao extends BaseDao<LogMapper, LogDto, LogKey> {
-
-  public LogDao() {
-    this(System2.INSTANCE);
-  }
-
-  @VisibleForTesting
-  public LogDao(System2 system) {
-    super(IndexDefinition.LOG, LogMapper.class, system);
-  }
-
-  @Override
-  protected LogDto doGetNullableByKey(DbSession session, LogKey key) {
-    return mapper(session).selectByKey(key);
-  }
-
-  @Override
-  protected LogDto doInsert(DbSession session, LogDto item) {
-    mapper(session).insert(item);
-    return item;
-  }
-
-  @Override
-  protected LogDto doUpdate(DbSession session, LogDto item) {
-   throw new IllegalStateException("Cannot update Log!");
-  }
-
-  @Override
-  protected void doDeleteByKey(DbSession session, LogKey key) {
-    throw new IllegalStateException("Cannot delete Log!");
-  }
-
-  public List<LogDto> findAll(DbSession session) {
-    return mapper(session).selectAll();
-  }
-
-  @Override
-  public void synchronizeAfter(DbSession session, long timestamp) {
-    throw new IllegalStateException("Log Index does not synchronize!");
-  }
-}
diff --git a/sonar-server/src/main/java/org/sonar/server/log/index/LogDoc.java b/sonar-server/src/main/java/org/sonar/server/log/index/LogDoc.java
deleted file mode 100644 (file)
index 3f96ac0..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.server.log.index;
-
-import org.sonar.core.log.Log;
-import org.sonar.server.search.BaseDoc;
-
-import java.util.Date;
-import java.util.Map;
-
-/**
- * @since 4.4
- */
-public class LogDoc extends BaseDoc implements Log {
-
-  protected LogDoc(Map<String, Object> fields) {
-    super(fields);
-  }
-
-  @Override
-  public Date time() {
-    return this.getField(LogNormalizer.LogFields.DATE.field());
-  }
-
-  @Override
-  public String author() {
-    return this.getField(LogNormalizer.LogFields.AUTHOR.field());
-  }
-
-  @Override
-  public Integer executionTime() {
-    return this.getField(LogNormalizer.LogFields.EXECUTION.field());
-  }
-
-  @Override
-  public Map<String, String> details() {
-    return this.getField(LogNormalizer.LogFields.DETAILS.field());
-  }
-
-  @Override
-  public String message() {
-    return this.getField(LogNormalizer.LogFields.MESSAGE.field());
-  }
-}
diff --git a/sonar-server/src/main/java/org/sonar/server/log/index/LogIndex.java b/sonar-server/src/main/java/org/sonar/server/log/index/LogIndex.java
deleted file mode 100644 (file)
index 9e677ee..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * 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.server.log.index;
-
-import org.elasticsearch.action.search.SearchRequestBuilder;
-import org.elasticsearch.action.search.SearchResponse;
-import org.elasticsearch.action.search.SearchType;
-import org.elasticsearch.common.settings.ImmutableSettings;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.unit.TimeValue;
-import org.elasticsearch.index.query.QueryBuilders;
-import org.sonar.core.cluster.WorkQueue;
-import org.sonar.core.log.Log;
-import org.sonar.core.log.db.LogDto;
-import org.sonar.core.log.db.LogKey;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.server.search.BaseIndex;
-import org.sonar.server.search.ESNode;
-import org.sonar.server.search.IndexDefinition;
-import org.sonar.server.search.IndexField;
-import org.sonar.server.search.QueryOptions;
-import org.sonar.server.search.Result;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @since 4.4
- */
-public class LogIndex extends BaseIndex<Log, LogDto, LogKey> {
-
-  public LogIndex(Profiling profiling, LogNormalizer normalizer, WorkQueue workQueue, ESNode node) {
-    super(IndexDefinition.LOG, normalizer, workQueue, node, profiling);
-  }
-
-  @Override
-  protected String getKeyValue(LogKey key) {
-    // FIXME too many collision with key.toString() due to lack of time precision
-    return null;// return key.toString();
-  }
-
-  @Override
-  protected Map mapKey() {
-    return null;
-    // Map<String, Object> mapping = new HashMap<String, Object>();
-    // return mapping;
-  }
-
-  @Override
-  protected Settings getIndexSettings() throws IOException {
-    return ImmutableSettings.builder().build();
-  }
-
-  @Override
-  protected Map mapProperties() {
-    Map<String, Object> mapping = new HashMap<String, Object>();
-    for (IndexField field : LogNormalizer.LogFields.ALL_FIELDS) {
-      mapping.put(field.field(), mapField(field));
-    }
-    return mapping;
-  }
-
-  @Override
-  protected Log toDoc(final Map<String, Object> fields) {
-    return new LogDoc(fields);
-  }
-
-  public Result<Log> findAll() {
-    return new Result<Log>(this, getClient().prepareSearch(this.getIndexName())
-      .setQuery(QueryBuilders.matchAllQuery())
-      .setTypes(this.getIndexType())
-      .setSize(Integer.MAX_VALUE)
-      .get());
-  }
-
-  public Result<Log> search(LogQuery query, QueryOptions options) {
-    SearchRequestBuilder esSearch = getClient()
-      .prepareSearch(this.getIndexName())
-      .setTypes(this.getIndexType())
-      .setIndices(this.getIndexName());
-
-    // TODO implement query and filters based on LogQuery
-    esSearch.setQuery(QueryBuilders.matchAllQuery());
-
-    if (options.isScroll()) {
-      esSearch.setSearchType(SearchType.SCAN);
-      esSearch.setScroll(TimeValue.timeValueMinutes(3));
-    }
-
-    SearchResponse esResult = esSearch.get();
-
-    return new Result<Log>(this, esResult);
-  }
-}
diff --git a/sonar-server/src/main/java/org/sonar/server/log/index/LogNormalizer.java b/sonar-server/src/main/java/org/sonar/server/log/index/LogNormalizer.java
deleted file mode 100644 (file)
index 933e9b8..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * 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.server.log.index;
-
-import com.google.common.collect.ImmutableList;
-import org.elasticsearch.action.support.replication.ReplicationType;
-import org.elasticsearch.action.update.UpdateRequest;
-import org.sonar.api.utils.KeyValueFormat;
-import org.sonar.core.log.db.LogDto;
-import org.sonar.core.log.db.LogKey;
-import org.sonar.core.persistence.DbSession;
-import org.sonar.server.db.DbClient;
-import org.sonar.server.search.BaseNormalizer;
-import org.sonar.server.search.IndexDefinition;
-import org.sonar.server.search.IndexField;
-import org.sonar.server.search.Indexable;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @since 4.4
- */
-public class LogNormalizer extends BaseNormalizer<LogDto, LogKey> {
-
-
-  public static final class LogFields extends Indexable {
-
-    public final static IndexField KEY = addSortableAndSearchable(IndexField.Type.STRING, "key");
-    public final static IndexField TYPE = addSortable(IndexField.Type.STRING, "type");
-    public final static IndexField DATE = addSortable(IndexField.Type.DATE, "date");
-    public final static IndexField EXECUTION = add(IndexField.Type.NUMERIC, "executionTime");
-    public final static IndexField AUTHOR = addSearchable(IndexField.Type.STRING, "author");
-    public final static IndexField DETAILS = addSearchable(IndexField.Type.OBJECT, "details");
-    public final static IndexField MESSAGE = addSearchable(IndexField.Type.STRING, "message");
-
-    public static Set<IndexField> ALL_FIELDS = getAllFields();
-
-    private static Set<IndexField> getAllFields() {
-      Set<IndexField> fields = new HashSet<IndexField>();
-      for (Field classField : LogFields.class.getDeclaredFields()) {
-        if (Modifier.isFinal(classField.getModifiers()) && Modifier.isStatic(classField.getModifiers())) {
-          try {
-            fields.add(IndexField.class.cast(classField.get(null)));
-          } catch (IllegalAccessException e) {
-            e.printStackTrace();
-          }
-        }
-      }
-      return fields;
-    }
-  }
-
-  public LogNormalizer(DbClient db) {
-    super(IndexDefinition.LOG, db);
-  }
-
-  @Override
-  public List<UpdateRequest> normalize(LogKey logKey) {
-    DbSession dbSession = db.openSession(false);
-    List<UpdateRequest> requests = new ArrayList<UpdateRequest>();
-    try {
-      requests.addAll(normalize(db.logDao().getNullableByKey(dbSession, logKey)));
-    } finally {
-      dbSession.close();
-    }
-    return requests;
-  }
-
-  @Override
-  public List<UpdateRequest> normalize(LogDto dto) {
-
-    Map<String, Object> logDoc = new HashMap<String, Object>();
-    logDoc.put(LogFields.KEY.field(), dto.getKey());
-    logDoc.put(LogFields.TYPE.field(), dto.getType());
-    logDoc.put(LogFields.AUTHOR.field(), dto.getAuthor());
-    logDoc.put(LogFields.MESSAGE.field(), dto.getMessage());
-    logDoc.put(LogFields.EXECUTION.field(), dto.getExecutionTime());
-    logDoc.put(LogFields.DATE.field(), dto.getCreatedAt());
-
-    logDoc.put(LogFields.DETAILS.field(), KeyValueFormat.parse(dto.getData()));
-
-   /* Creating updateRequest */
-    return ImmutableList.of(new UpdateRequest()
-      //Need to make a UUID because Key does not insure unicity
-      .replicationType(ReplicationType.ASYNC)
-      .doc(logDoc)
-      .upsert(logDoc));
-  }
-}
diff --git a/sonar-server/src/main/java/org/sonar/server/log/index/LogQuery.java b/sonar-server/src/main/java/org/sonar/server/log/index/LogQuery.java
deleted file mode 100644 (file)
index 83667cd..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.server.log.index;
-
-import org.sonar.core.log.Log;
-
-import java.util.Collection;
-import java.util.Date;
-
-/**
- * @since 4.4
- */
-public class LogQuery {
-
-  private Date since;
-  private Date to;
-  private Collection<Log.Type> types;
-
-  public LogQuery() {
-  }
-
-  public Date getSince() {
-    return since;
-  }
-
-  public void setSince(Date since) {
-    this.since = since;
-  }
-
-  public Date getTo() {
-    return to;
-  }
-
-  public void setTo(Date to) {
-    this.to = to;
-  }
-
-  public Collection<Log.Type> getTypes() {
-    return types;
-  }
-
-  public void setTypes(Collection<Log.Type> types) {
-    this.types = types;
-  }
-}
diff --git a/sonar-server/src/main/java/org/sonar/server/log/ws/LogMapping.java b/sonar-server/src/main/java/org/sonar/server/log/ws/LogMapping.java
deleted file mode 100644 (file)
index 534ef42..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.server.log.ws;
-
-import org.sonar.api.resources.Languages;
-import org.sonar.api.utils.text.JsonWriter;
-import org.sonar.core.log.Log;
-import org.sonar.server.log.index.LogNormalizer;
-import org.sonar.server.search.ws.BaseMapping;
-import org.sonar.server.text.MacroInterpreter;
-
-import java.util.Map;
-
-/**
- * Conversion between Log and WS JSON response
- */
-public class LogMapping extends BaseMapping {
-
-
-  public LogMapping(Languages languages, MacroInterpreter macroInterpreter) {
-    super();
-    addIndexStringField("key", LogNormalizer.LogFields.KEY.field());
-    addIndexStringField("type", LogNormalizer.LogFields.TYPE.field());
-    addIndexDatetimeField("createdAt", LogNormalizer.LogFields.DATE.field());
-    addIndexStringField("userLogin", LogNormalizer.LogFields.AUTHOR.field());
-    addIndexStringField("message", LogNormalizer.LogFields.MESSAGE.field());
-    addIndexStringField("executionTime", LogNormalizer.LogFields.EXECUTION.field());
-    addField("details", new DetailField());
-  }
-
-  private static class DetailField extends IndexField<Log> {
-    DetailField() {
-      super(LogNormalizer.LogFields.DETAILS.field());
-    }
-
-    @Override
-    public void write(JsonWriter json, Log log) {
-      json.name("details").beginObject();
-      for (Map.Entry<String, String> detail : log.details().entrySet()) {
-        json.prop(detail.getKey(), detail.getValue());
-      }
-      json.endObject();
-    }
-  }
-}
diff --git a/sonar-server/src/main/java/org/sonar/server/log/ws/LogsWebService.java b/sonar-server/src/main/java/org/sonar/server/log/ws/LogsWebService.java
deleted file mode 100644 (file)
index 9ce5123..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.server.log.ws;
-
-import org.sonar.api.server.ws.WebService;
-
-public class LogsWebService implements WebService {
-
-  public static final String API_ENDPOINT = "api/logs";
-
-  private final SearchAction search;
-
-  public LogsWebService(SearchAction search) {
-    this.search = search;
-  }
-
-  @Override
-  public void define(Context context) {
-    NewController controller = context
-      .createController(API_ENDPOINT)
-      .setDescription("Logs search and views");
-
-    search.define(controller);
-    controller.done();
-  }
-}
diff --git a/sonar-server/src/main/java/org/sonar/server/log/ws/SearchAction.java b/sonar-server/src/main/java/org/sonar/server/log/ws/SearchAction.java
deleted file mode 100644 (file)
index f4defda..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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.server.log.ws;
-
-import org.apache.commons.lang.StringUtils;
-import org.sonar.api.server.ws.Request;
-import org.sonar.api.server.ws.RequestHandler;
-import org.sonar.api.server.ws.Response;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.api.utils.text.JsonWriter;
-import org.sonar.core.log.Log;
-import org.sonar.server.log.LogService;
-import org.sonar.server.log.index.LogDoc;
-import org.sonar.server.log.index.LogQuery;
-import org.sonar.server.search.QueryOptions;
-import org.sonar.server.search.Result;
-import org.sonar.server.search.ws.SearchOptions;
-
-/**
- * @since 4.4
- */
-public class SearchAction implements RequestHandler {
-
-  public static final String PARAM_TYPE = "type";
-
-  public static final String SEARCH_ACTION = "search";
-
-  private final LogService logService;
-  private final LogMapping mapping;
-
-  public SearchAction(LogService logService, LogMapping mapping) {
-    this.logService = logService;
-    this.mapping = mapping;
-  }
-
-  void define(WebService.NewController controller) {
-    WebService.NewAction action = controller
-      .createAction(SEARCH_ACTION)
-      .setDescription("Search for a logs")
-      .setSince("4.4")
-      .setHandler(this);
-
-    // Other parameters
-    action.createParam(PARAM_TYPE)
-      .setDescription("Select types of log to search")
-      .setPossibleValues(Log.Type.values())
-      .setDefaultValue(StringUtils.join(Log.Type.values(), ","));
-
-    // Generic search parameters
-    SearchOptions.defineFieldsParam(action, mapping.supportedFields());
-
-    SearchOptions.definePageParams(action);
-  }
-
-  @Override
-  public void handle(Request request, Response response) {
-    LogQuery query = createLogQuery(logService.newLogQuery(), request);
-    SearchOptions searchOptions = SearchOptions.create(request);
-    QueryOptions queryOptions = mapping.newQueryOptions(searchOptions);
-
-    Result<Log> results = logService.search(query, queryOptions);
-
-    JsonWriter json = response.newJsonWriter().beginObject();
-    searchOptions.writeStatistics(json, results);
-    writeLogs(results, json, searchOptions);
-    json.endObject().close();
-  }
-
-  public static LogQuery createLogQuery(LogQuery query, Request request) {
-    // query.setTypes(request.param(SearchOptions.PARAM_TEXT_QUERY));
-    return query;
-  }
-
-  private void writeLogs(Result<Log> result, JsonWriter json, SearchOptions options) {
-    json.name("logs").beginArray();
-    for (Log log : result.getHits()) {
-      mapping.write((LogDoc) log, json, options);
-    }
-    json.endArray();
-  }
-}
index 500dd388aa34f9ab97ac9c0e815e0ac206967911..53cf7624a84ebebffdd28a6ab87fc6c945077b40 100644 (file)
@@ -77,6 +77,12 @@ import org.sonar.jpa.session.DatabaseSessionFactory;
 import org.sonar.jpa.session.DatabaseSessionProvider;
 import org.sonar.jpa.session.DefaultDatabaseConnector;
 import org.sonar.jpa.session.ThreadLocalDatabaseSessionFactory;
+import org.sonar.server.activity.ActivityService;
+import org.sonar.server.activity.db.ActivityDao;
+import org.sonar.server.activity.index.ActivityIndex;
+import org.sonar.server.activity.index.ActivityNormalizer;
+import org.sonar.server.activity.ws.ActivitiesWebService;
+import org.sonar.server.activity.ws.ActivityMapping;
 import org.sonar.server.authentication.ws.AuthenticationWs;
 import org.sonar.server.charts.ChartFactory;
 import org.sonar.server.component.DefaultComponentFinder;
@@ -126,12 +132,6 @@ import org.sonar.server.issue.ws.IssueActionsWriter;
 import org.sonar.server.issue.ws.IssueSearchAction;
 import org.sonar.server.issue.ws.IssueShowAction;
 import org.sonar.server.issue.ws.IssuesWs;
-import org.sonar.server.log.LogService;
-import org.sonar.server.log.db.LogDao;
-import org.sonar.server.log.index.LogIndex;
-import org.sonar.server.log.index.LogNormalizer;
-import org.sonar.server.log.ws.LogMapping;
-import org.sonar.server.log.ws.LogsWebService;
 import org.sonar.server.measure.MeasureFilterEngine;
 import org.sonar.server.measure.MeasureFilterExecutor;
 import org.sonar.server.measure.MeasureFilterFactory;
@@ -322,7 +322,7 @@ class ServerComponents {
       ComponentDao.class,
       DbClient.class,
       MeasureFilterDao.class,
-      LogDao.class,
+      ActivityDao.class,
 
       // Elasticsearch
       ESNode.class,
@@ -332,11 +332,11 @@ class ServerComponents {
       ActiveRuleIndex.class,
       IndexQueueWorker.class,
       IndexClient.class,
-      LogNormalizer.class,
-      LogIndex.class,
+      ActivityNormalizer.class,
+      ActivityIndex.class,
 
       // LogService
-      LogService.class
+      ActivityService.class
 
     ));
     components.addAll(CorePropertyDefinitions.all());
@@ -463,9 +463,9 @@ class ServerComponents {
     pico.addSingleton(ActiveRuleCompleter.class);
     pico.addSingleton(AppAction.class);
 
-    pico.addSingleton(LogsWebService.class);
-    pico.addSingleton(org.sonar.server.log.ws.SearchAction.class);
-    pico.addSingleton(LogMapping.class);
+    pico.addSingleton(ActivitiesWebService.class);
+    pico.addSingleton(SearchAction.class);
+    pico.addSingleton(ActivityMapping.class);
 
 
     // measure
index 685e7a7c1c435b700cf45c776bf27fbb4fdb617c..49080606c175be8a268644c4a38f27aab78f0907 100644 (file)
@@ -21,14 +21,15 @@ package org.sonar.server.qualityprofile;
 
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Maps;
-import org.sonar.core.log.Loggable;
+import org.apache.commons.lang.StringUtils;
+import org.sonar.core.activity.ActivityLog;
 import org.sonar.core.qualityprofile.db.ActiveRuleKey;
 
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 import java.util.Map;
 
-public class ActiveRuleChange implements Loggable {
+public class ActiveRuleChange implements ActivityLog {
 
   static enum Type {
     ACTIVATED, DEACTIVATED, UPDATED
@@ -103,6 +104,17 @@ public class ActiveRuleChange implements Loggable {
       details.put("ruleKey", getKey().ruleKey().toString());
       details.put("profileKey", getKey().qProfile().toString());
     }
+    if (!parameters.isEmpty()) {
+      for (Map.Entry<String, String> param : parameters.entrySet()) {
+        details.put("param_" + param.getKey(), param.getValue());
+      }
+    }
+    if (StringUtils.isNotEmpty(severity)) {
+      details.put("severity", severity);
+    }
+    if (inheritance != null) {
+      details.put("inheritance", inheritance.name());
+    }
     return details.build();
   }
 
index 278f345089eeb5769b7ea1e49f99af16c6dc5ac3..30305fd41be97db4a98d0c3ed844310c48e15dec 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.qualityprofile;
 
-import com.google.common.collect.ArrayListMultimap;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Multimap;
 import org.sonar.api.ServerComponent;
@@ -220,19 +219,16 @@ public class QProfileService implements ServerComponent {
     return counts;
   }
 
-  public Multimap<QualityProfileKey, FacetValue> getAllProfileStats() {
+  public Multimap<String, FacetValue> getStatsByProfile(QualityProfileKey key) {
+    return index.get(ActiveRuleIndex.class).getStatsByProfileKey(key);
+  }
+
+  public Map<QualityProfileKey, Multimap<String, FacetValue>> getAllProfileStats() {
 
     List<QualityProfileKey> keys = Lists.newArrayList();
     for (QualityProfileDto profile : this.findAll()) {
       keys.add(profile.getKey());
     }
-
-    Multimap<QualityProfileKey, FacetValue> stats = ArrayListMultimap.create();
-
-    Collection<FacetValue> profilesStats = index.get(ActiveRuleIndex.class).getStatsByProfileKey(keys);
-    for (FacetValue profileStat : profilesStats) {
-      stats.put(QualityProfileKey.parse(profileStat.getKey()), profileStat);
-    }
-    return stats;
+    return index.get(ActiveRuleIndex.class).getStatsByProfileKey(keys);
   }
 }
index 944748270d6ed35f10defa319f80927e604bb702..35c000e5a3751758aaf4f798f4fa8ac8ecd3307d 100644 (file)
@@ -24,7 +24,7 @@ import com.google.common.collect.Lists;
 import org.apache.commons.lang.StringUtils;
 import org.sonar.api.ServerComponent;
 import org.sonar.api.server.rule.RuleParamType;
-import org.sonar.core.log.Log;
+import org.sonar.core.activity.Activity;
 import org.sonar.core.persistence.DbSession;
 import org.sonar.core.preview.PreviewCache;
 import org.sonar.core.qualityprofile.db.ActiveRuleDto;
@@ -36,7 +36,7 @@ import org.sonar.core.rule.RuleDto;
 import org.sonar.core.rule.RuleParamDto;
 import org.sonar.server.db.DbClient;
 import org.sonar.server.exceptions.BadRequestException;
-import org.sonar.server.log.LogService;
+import org.sonar.server.log.ActivityService;
 import org.sonar.server.qualityprofile.db.ActiveRuleDao;
 import org.sonar.server.rule.Rule;
 import org.sonar.server.rule.index.RuleIndex;
@@ -47,7 +47,6 @@ import org.sonar.server.search.Result;
 import org.sonar.server.util.TypeValidations;
 
 import javax.annotation.Nullable;
-
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -64,11 +63,11 @@ public class RuleActivator implements ServerComponent {
   private final RuleActivatorContextFactory contextFactory;
   private final PreviewCache previewCache;
   private final IndexClient index;
-  private final LogService log;
+  private final ActivityService log;
 
   public RuleActivator(DbClient db, IndexClient index,
-    RuleActivatorContextFactory contextFactory, TypeValidations typeValidations,
-    PreviewCache previewCache, LogService log) {
+                       RuleActivatorContextFactory contextFactory, TypeValidations typeValidations,
+                       PreviewCache previewCache, ActivityService log) {
     this.db = db;
     this.index = index;
     this.contextFactory = contextFactory;
@@ -140,7 +139,7 @@ public class RuleActivator implements ServerComponent {
     }
 
     if (!changes.isEmpty()) {
-      log.write(dbSession, Log.Type.ACTIVE_RULE, changes);
+      log.write(dbSession, Activity.Type.ACTIVE_RULE, changes);
       previewCache.reportGlobalModification();
     }
     return changes;
@@ -151,7 +150,7 @@ public class RuleActivator implements ServerComponent {
    * 1. defined by end-user
    * 2. else inherited from parent profile
    * 3. else defined by rule defaults
-   *
+   * <p/>
    * On custom rules, it's always rule parameters that are used
    */
   private void applySeverityAndParamToChange(RuleActivation activation, RuleActivatorContext context, ActiveRuleChange change) {
@@ -301,7 +300,7 @@ public class RuleActivator implements ServerComponent {
     }
 
     if (!changes.isEmpty()) {
-      log.write(dbSession, Log.Type.ACTIVE_RULE, changes);
+      log.write(dbSession, Activity.Type.ACTIVE_RULE, changes);
       previewCache.reportGlobalModification();
     }
 
index acc610c586336ee44cce1e0f15bcc904fde0250e..7829d94e450bf67db4baa8b8ee899c8e6fb8e57b 100644 (file)
@@ -63,7 +63,6 @@ import org.sonar.server.search.IndexField;
 
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -181,30 +180,35 @@ public class ActiveRuleIndex extends BaseIndex<ActiveRule, ActiveRuleDto, Active
     return request.get().getCount();
   }
 
-
-  public Collection<FacetValue> getStatsByProfileKey(List<QualityProfileKey> keys) {
-
-    // Get QProfiles keys as Strings
-    String[] stringKeys = new String[keys.size()];
-    for (int i = 0; i < keys.size(); i++) {
-      stringKeys[i] = keys.get(i).toString();
-    }
+  public Multimap<String, FacetValue> getStatsByProfileKey(QualityProfileKey key) {
 
     SearchResponse response = getClient().prepareSearch(this.getIndexName())
       .setQuery(QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(),
-        FilterBuilders.termsFilter(ActiveRuleNormalizer.ActiveRuleField.PROFILE_KEY.field(), stringKeys)))
+        FilterBuilders.termsFilter(ActiveRuleNormalizer.ActiveRuleField.PROFILE_KEY.field(), key.toString())))
       .addAggregation(AggregationBuilders.terms(ActiveRuleNormalizer.ActiveRuleField.PROFILE_KEY.field())
         .field(ActiveRuleNormalizer.ActiveRuleField.PROFILE_KEY.field())
         .subAggregation(AggregationBuilders.terms(ActiveRuleNormalizer.ActiveRuleField.INHERITANCE.field())
           .field(ActiveRuleNormalizer.ActiveRuleField.INHERITANCE.field())
           .subAggregation(AggregationBuilders.terms(ActiveRuleNormalizer.ActiveRuleField.SEVERITY.field())
             .field(ActiveRuleNormalizer.ActiveRuleField.SEVERITY.field()))))
+      .addAggregation(AggregationBuilders.terms(ActiveRuleNormalizer.ActiveRuleField.INHERITANCE.field())
+        .field(ActiveRuleNormalizer.ActiveRuleField.INHERITANCE.field()))
+      .addAggregation(AggregationBuilders.terms(ActiveRuleNormalizer.ActiveRuleField.SEVERITY.field())
+        .field(ActiveRuleNormalizer.ActiveRuleField.SEVERITY.field()))
+
       .setSize(0)
       .setTypes(this.getIndexType())
       .get();
 
-    Multimap<String, FacetValue> stats = this.processAggregations(response.getAggregations());
+    return this.processAggregations(response.getAggregations());
+  }
 
-    return stats.get(ActiveRuleNormalizer.ActiveRuleField.PROFILE_KEY.field());
+  public Map<QualityProfileKey, Multimap<String, FacetValue>> getStatsByProfileKey(List<QualityProfileKey> keys) {
+    //TODO Optimize in a single request.
+    Map<QualityProfileKey, Multimap<String, FacetValue>> stats = new HashMap<QualityProfileKey, Multimap<String, FacetValue>>();
+    for (QualityProfileKey key : keys) {
+      stats.put(key, getStatsByProfileKey(key));
+    }
+    return stats;
   }
 }
index a90898cadec7b59b256046427f72a87fcedfce7f..7841c00437aadc4b4b195485ba17973802ed0c88 100644 (file)
@@ -25,13 +25,13 @@ import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Test;
 import org.sonar.api.rule.RuleKey;
-import org.sonar.core.log.Log;
+import org.sonar.core.activity.Activity;
 import org.sonar.core.persistence.DbSession;
 import org.sonar.core.qualityprofile.db.ActiveRuleKey;
 import org.sonar.core.qualityprofile.db.QualityProfileKey;
+import org.sonar.server.activity.ActivityService;
+import org.sonar.server.activity.index.ActivityIndex;
 import org.sonar.server.db.DbClient;
-import org.sonar.server.log.LogService;
-import org.sonar.server.log.index.LogIndex;
 import org.sonar.server.tester.ServerTester;
 
 import static org.fest.assertions.Assertions.assertThat;
@@ -42,8 +42,8 @@ public class ActiveRuleChangeMediumTest {
   @ClassRule
   public static ServerTester tester = new ServerTester();
 
-  LogService service = tester.get(LogService.class);
-  LogIndex index = tester.get(LogIndex.class);
+  ActivityService service = tester.get(ActivityService.class);
+  ActivityIndex index = tester.get(ActivityIndex.class);
   DbClient db;
   DbSession dbSession;
 
@@ -70,14 +70,14 @@ public class ActiveRuleChangeMediumTest {
       .setSeverity("BLOCKER")
       .setParameter("param1", "value1");
 
-    service.write(dbSession, Log.Type.ACTIVE_RULE, change);
+    service.write(dbSession, Activity.Type.ACTIVE_RULE, change);
     dbSession.commit();
 
     // 0. AssertBase case
     assertThat(index.findAll().getHits()).hasSize(1);
 
-    Log log = Iterables.getFirst(index.findAll().getHits(), null);
-    assertThat(log).isNotNull();
-    assertThat(log.details().get("key")).isEqualTo(key.toString());
+    Activity activity = Iterables.getFirst(index.findAll().getHits(), null);
+    assertThat(activity).isNotNull();
+    assertThat(activity.details().get("key")).isEqualTo(key.toString());
   }
 }
\ No newline at end of file
diff --git a/sonar-server/src/test/java/org/sonar/server/startup/ActivityServerIdTest.java b/sonar-server/src/test/java/org/sonar/server/startup/ActivityServerIdTest.java
new file mode 100644 (file)
index 0000000..96ecafa
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * 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.server.startup;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.slf4j.Logger;
+import org.sonar.api.CoreProperties;
+import org.sonar.core.properties.PropertiesDao;
+import org.sonar.core.properties.PropertyDto;
+
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.*;
+
+public class ActivityServerIdTest {
+
+  @Mock
+  private PropertiesDao dao;
+
+  @Mock
+  private Logger logger;
+
+  private LogServerId logServerId;
+
+  @Before
+  public void init() {
+    MockitoAnnotations.initMocks(this);
+
+    when(dao.selectGlobalProperty(CoreProperties.PERMANENT_SERVER_ID)).thenReturn(new PropertyDto().setValue("123456789"));
+    when(dao.selectGlobalProperty(CoreProperties.ORGANISATION)).thenReturn(new PropertyDto().setValue("SonarSource"));
+    when(dao.selectGlobalProperty(CoreProperties.SERVER_ID_IP_ADDRESS)).thenReturn(new PropertyDto().setValue("1.2.3.4"));
+
+    logServerId = new LogServerId(dao);
+  }
+
+  @Test
+  public void shouldLogMessage() {
+    logServerId.logServerId(logger);
+
+    String log =
+      "Server information:\n"
+        + "  - ID            : \"123456789\"\n"
+        + "  - Organisation  : \"SonarSource\"\n"
+        + "  - Registered IP : \"1.2.3.4\"\n";
+
+    verify(logger, times(1)).info(log);
+  }
+
+  @Test
+  public void shouldNotLogMessage() {
+    when(dao.selectGlobalProperty(CoreProperties.PERMANENT_SERVER_ID)).thenReturn(null);
+
+    logServerId.logServerId(logger);
+
+    verify(logger, never()).info(anyString());
+  }
+
+  @Test
+  public void testStartMethod() {
+    // just to have 100% coverage ;-)
+    logServerId.start();
+  }
+
+}
diff --git a/sonar-server/src/test/java/org/sonar/server/startup/LogServerIdTest.java b/sonar-server/src/test/java/org/sonar/server/startup/LogServerIdTest.java
deleted file mode 100644 (file)
index 4e819bd..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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.server.startup;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.slf4j.Logger;
-import org.sonar.api.CoreProperties;
-import org.sonar.core.properties.PropertiesDao;
-import org.sonar.core.properties.PropertyDto;
-
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class LogServerIdTest {
-
-  @Mock
-  private PropertiesDao dao;
-
-  @Mock
-  private Logger logger;
-
-  private LogServerId logServerId;
-
-  @Before
-  public void init() {
-    MockitoAnnotations.initMocks(this);
-
-    when(dao.selectGlobalProperty(CoreProperties.PERMANENT_SERVER_ID)).thenReturn(new PropertyDto().setValue("123456789"));
-    when(dao.selectGlobalProperty(CoreProperties.ORGANISATION)).thenReturn(new PropertyDto().setValue("SonarSource"));
-    when(dao.selectGlobalProperty(CoreProperties.SERVER_ID_IP_ADDRESS)).thenReturn(new PropertyDto().setValue("1.2.3.4"));
-
-    logServerId = new LogServerId(dao);
-  }
-
-  @Test
-  public void shouldLogMessage() {
-    logServerId.logServerId(logger);
-
-    String log =
-        "Server information:\n"
-          + "  - ID            : \"123456789\"\n"
-          + "  - Organisation  : \"SonarSource\"\n"
-          + "  - Registered IP : \"1.2.3.4\"\n";
-
-    verify(logger, times(1)).info(log);
-  }
-
-  @Test
-  public void shouldNotLogMessage() {
-    when(dao.selectGlobalProperty(CoreProperties.PERMANENT_SERVER_ID)).thenReturn(null);
-
-    logServerId.logServerId(logger);
-
-    verify(logger, never()).info(anyString());
-  }
-
-  @Test
-  public void testStartMethod() {
-    // just to have 100% coverage ;-)
-    logServerId.start();
-  }
-
-}