IDEA-259507: rename BaseValidationRuleStorage and SensitiveDataValidator
authorAnastasia Ivanova <anastasia.ivanova@jetbrains.com>
Fri, 22 Jan 2021 19:34:58 +0000 (20:34 +0100)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Wed, 27 Jan 2021 13:22:32 +0000 (13:22 +0000)
GitOrigin-RevId: e96d59300c21b701c1415301a85e7d62fb1cf48e

25 files changed:
platform/platform-tests/testSrc/com/intellij/internal/statistics/metadata/storage/CompositeValidationRulesStorageTest.kt
platform/platform-tests/testSrc/com/intellij/internal/statistics/metadata/storage/ValidationRulesBaseStorageTest.kt
platform/platform-tests/testSrc/com/intellij/internal/statistics/metadata/validator/BaseSensitiveDataValidatorTest.kt
platform/platform-tests/testSrc/com/intellij/internal/statistics/metadata/validator/SensitiveDataValidatorTest.kt
platform/statistics/devkit/src/com/intellij/internal/statistic/actions/ConfigureEventsSchemeFileAction.kt
platform/statistics/devkit/src/com/intellij/internal/statistic/actions/UpdateEventsSchemeAction.kt
platform/statistics/devkit/testSrc/com/intellij/internal/statistic/actions/CleanupEventsTestSchemeActionTest.kt
platform/statistics/src/com/intellij/internal/statistic/eventLog/EventLogGroup.kt
platform/statistics/src/com/intellij/internal/statistic/eventLog/StatisticsFileEventLogger.kt
platform/statistics/src/com/intellij/internal/statistic/eventLog/validator/IntellijSensitiveDataValidator.java [moved from platform/statistics/src/com/intellij/internal/statistic/eventLog/validator/SensitiveDataValidator.java with 86% similarity]
platform/statistics/src/com/intellij/internal/statistic/eventLog/validator/rules/impl/CustomValidationRule.java
platform/statistics/src/com/intellij/internal/statistic/eventLog/validator/storage/CompositeValidationRulesStorage.java
platform/statistics/src/com/intellij/internal/statistic/eventLog/validator/storage/IntellijValidationRulesStorage.java [moved from platform/statistics/src/com/intellij/internal/statistic/eventLog/validator/storage/ValidationRulesStorage.java with 84% similarity]
platform/statistics/src/com/intellij/internal/statistic/eventLog/validator/storage/ValidationRulesInMemoryStorage.kt
platform/statistics/src/com/intellij/internal/statistic/eventLog/validator/storage/ValidationRulesPersistedStorage.java
platform/statistics/src/com/intellij/internal/statistic/eventLog/validator/storage/ValidationRulesStorageProvider.java
platform/statistics/src/com/intellij/internal/statistic/eventLog/validator/storage/ValidationTestRulesPersistedStorage.java
platform/statistics/src/com/intellij/internal/statistic/service/fus/collectors/ApplicationUsagesCollector.java
platform/statistics/src/com/intellij/internal/statistic/service/fus/collectors/CounterUsagesCollector.java
platform/statistics/src/com/intellij/internal/statistic/service/fus/collectors/ProjectUsagesCollector.java
platform/statistics/src/com/intellij/internal/statistic/updater/StatisticsJobsScheduler.java
platform/statistics/validator/README.MD
platform/statistics/validator/src/com/intellij/internal/statistic/eventLog/validator/SensitiveDataValidator.kt [moved from platform/statistics/validator/src/com/intellij/internal/statistic/eventLog/validator/SimpleSensitiveDataValidator.kt with 97% similarity]
platform/statistics/validator/src/com/intellij/internal/statistic/eventLog/validator/SimpleValidationRuleStorage.kt
platform/statistics/validator/src/com/intellij/internal/statistic/eventLog/validator/ValidationRuleStorage.kt [moved from platform/statistics/validator/src/com/intellij/internal/statistic/eventLog/validator/BaseValidationRuleStorage.kt with 83% similarity]

index 9aec272122470015c2fcb7b9fba1cb92e9f6d657..ff034d2f84ba557ca85635b332d4446afb3392a5 100644 (file)
@@ -1,7 +1,7 @@
 // Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
 package com.intellij.internal.statistics.metadata.storage
 
-import com.intellij.internal.statistic.eventLog.validator.SensitiveDataValidator
+import com.intellij.internal.statistic.eventLog.validator.IntellijSensitiveDataValidator
 import com.intellij.internal.statistic.eventLog.validator.rules.beans.EventGroupRules
 import com.intellij.internal.statistic.eventLog.validator.storage.ValidationRulesInMemoryStorage
 import com.intellij.internal.statistic.eventLog.validator.storage.GroupValidationTestRule
@@ -16,7 +16,7 @@ internal class CompositeValidationRulesStorageTest : ValidationRulesBaseStorageT
   }
 
   fun testGetGroupRulesFromTest() {
-    val storage = SensitiveDataValidator.getInstance(recorderId).validationRulesStorage
+    val storage = IntellijSensitiveDataValidator.getInstance(recorderId).validationRulesStorage
     ValidationTestRulesPersistedStorage.getTestStorage(recorderId, true)!!
       .addTestGroup(GroupValidationTestRule(
         groupId,
@@ -36,7 +36,7 @@ internal class CompositeValidationRulesStorageTest : ValidationRulesBaseStorageT
   }
 
   fun testGetGroupRules() {
-    val mergedStorage = SensitiveDataValidator.getInstance(recorderId).validationRulesStorage
+    val mergedStorage = IntellijSensitiveDataValidator.getInstance(recorderId).validationRulesStorage
     ValidationRulesInMemoryStorage.eventsValidators[groupId] = EventGroupRules.EMPTY
 
     val groupRules = mergedStorage.getGroupRules(groupId)
index 208c35bc358cc14beac8c4fa8dc6f1082128db1e..6820a2feeccc79f6172274bcc2d4a1438a85f476 100644 (file)
@@ -1,7 +1,7 @@
 // Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
 package com.intellij.internal.statistics.metadata.storage
 
-import com.intellij.internal.statistic.eventLog.validator.SensitiveDataValidator
+import com.intellij.internal.statistic.eventLog.validator.IntellijSensitiveDataValidator
 import com.intellij.internal.statistic.eventLog.validator.storage.ValidationTestRulesPersistedStorage
 import com.intellij.internal.statistic.eventLog.validator.storage.persistence.EventLogTestMetadataPersistence
 import com.intellij.openapi.util.io.FileUtil
@@ -20,7 +20,7 @@ internal abstract class ValidationRulesBaseStorageTest : BasePlatformTestCase()
 
     // initialize validation rules storage
     for (recorder in recordersToCleanUp) {
-      SensitiveDataValidator.getInstance(recorder)
+      IntellijSensitiveDataValidator.getInstance(recorder)
     }
   }
 
index 91f4aea162aff220e1554795ce2289d9a9385395..db6d29b222e6e82966000b68d52c2987b9661922 100644 (file)
@@ -4,7 +4,7 @@ package com.intellij.internal.statistics.metadata.validator
 import com.intellij.internal.statistic.eventLog.EventLogBuild
 import com.intellij.internal.statistic.eventLog.EventLogGroup
 import com.intellij.internal.statistic.eventLog.connection.metadata.EventGroupRemoteDescriptors
-import com.intellij.internal.statistic.eventLog.validator.SensitiveDataValidator
+import com.intellij.internal.statistic.eventLog.validator.IntellijSensitiveDataValidator
 import com.intellij.internal.statistic.eventLog.validator.ValidationResultType
 import com.intellij.internal.statistic.eventLog.validator.rules.EventContext
 import com.intellij.internal.statistic.eventLog.validator.rules.FUSRule
@@ -68,7 +68,7 @@ abstract class BaseSensitiveDataValidatorTest  : UsefulTestCase() {
   }
 }
 
-internal class TestSensitiveDataValidator(storage: ValidationRulesPersistedStorage) : SensitiveDataValidator(storage) {
+internal class TestSensitiveDataValidator(storage: ValidationRulesPersistedStorage) : IntellijSensitiveDataValidator(storage) {
   fun getEventRules(group: EventLogGroup): Array<FUSRule> {
     val rules = validationRulesStorage.getGroupRules(group.id)
 
index 545756a62041d86cdfec950fecc6a1ca26913748..69edf3b25dd55b8a250ed0eb0382bbc0995c3f37 100644 (file)
@@ -3,7 +3,6 @@ package com.intellij.internal.statistics.metadata.validator
 
 import com.intellij.internal.statistic.eventLog.EventLogGroup
 import com.intellij.internal.statistic.eventLog.FeatureUsageData
-import com.intellij.internal.statistic.eventLog.validator.SensitiveDataValidator
 import com.intellij.internal.statistic.eventLog.validator.ValidationResultType
 import com.intellij.internal.statistic.eventLog.validator.rules.EventContext
 import com.intellij.internal.statistic.eventLog.validator.rules.impl.CustomValidationRule
index 3b9463a779fb68de4c6231d096d60486de8aa776..053c05c76ae60b8fd07d0fc403f06fd90c27bf53 100644 (file)
@@ -4,7 +4,7 @@ package com.intellij.internal.statistic.actions
 import com.intellij.icons.AllIcons
 import com.intellij.idea.ActionsBundle
 import com.intellij.internal.statistic.StatisticsDevKitUtil
-import com.intellij.internal.statistic.eventLog.validator.SensitiveDataValidator
+import com.intellij.internal.statistic.eventLog.validator.IntellijSensitiveDataValidator
 import com.intellij.internal.statistic.eventLog.validator.storage.persistence.EventLogMetadataSettingsPersistence
 import com.intellij.internal.statistic.eventLog.validator.storage.persistence.EventsSchemePathSettings
 import com.intellij.internal.statistic.eventLog.validator.rules.impl.TestModeValidationRule
@@ -53,7 +53,7 @@ class ConfigureEventsSchemeFileAction(private var myRecorderId: String = Statist
           settingsPersistence.setPathSettings(recorder, EventsSchemePathSettings(oldSettings.customPath, false))
         }
       }
-      val validator = SensitiveDataValidator.getInstance(recorder)
+      val validator = IntellijSensitiveDataValidator.getInstance(recorder)
       validator.update()
       validator.reload()
     }
index 34054ef903c20b800ae3028f09c46d6345ff997a..92a185ef5ccc8afd208c27185f2db2604fe56764 100644 (file)
@@ -4,7 +4,7 @@ package com.intellij.internal.statistic.actions
 import com.intellij.icons.AllIcons
 import com.intellij.idea.ActionsBundle
 import com.intellij.internal.statistic.StatisticsBundle
-import com.intellij.internal.statistic.eventLog.validator.SensitiveDataValidator
+import com.intellij.internal.statistic.eventLog.validator.IntellijSensitiveDataValidator
 import com.intellij.openapi.actionSystem.AnActionEvent
 import com.intellij.openapi.progress.ProgressIndicator
 import com.intellij.openapi.progress.ProgressManager
@@ -20,7 +20,7 @@ class UpdateEventsSchemeAction(val recorder: String)
 
     ProgressManager.getInstance().run(object : Task.Backgroundable(project, StatisticsBundle.message("stats.updating.events.scheme"), false) {
       override fun run(indicator: ProgressIndicator) {
-        val validator = SensitiveDataValidator.getInstance(recorder)
+        val validator = IntellijSensitiveDataValidator.getInstance(recorder)
         validator.update()
         validator.reload()
       }
index c129b2b1ca242910726607ab2d092fd37bfa578f..d6a2886f094272614cb17b6eaef23e1d449614b6 100644 (file)
@@ -1,7 +1,7 @@
 // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
 package com.intellij.internal.statistic.actions
 
-import com.intellij.internal.statistic.eventLog.validator.SensitiveDataValidator
+import com.intellij.internal.statistic.eventLog.validator.IntellijSensitiveDataValidator
 import com.intellij.internal.statistic.eventLog.validator.storage.GroupValidationTestRule
 import com.intellij.internal.statistic.eventLog.validator.storage.ValidationTestRulesPersistedStorage
 import com.intellij.openapi.actionSystem.ActionManager
@@ -19,7 +19,7 @@ class CleanupEventsTestSchemeActionTest : BasePlatformTestCase() {
     val groupId = "test.group"
     val recorderId = "FUS"
 
-    SensitiveDataValidator.getInstance(recorderId)
+    IntellijSensitiveDataValidator.getInstance(recorderId)
     ValidationTestRulesPersistedStorage.getTestStorage(recorderId, true)!!.addTestGroup(GroupValidationTestRule("groupId", false))
     val dataContext = SimpleDataContext.getProjectContext(myFixture.project)
     val e = AnActionEvent(null, dataContext, "test", Presentation(), ActionManager.getInstance(), 0)
index 4606df40cec24ec7ac9b6c12a61ae8c3962b8610..02415b6efb20a03b37f020cbd28f846096532b63 100644 (file)
@@ -26,7 +26,7 @@ class EventLogGroup(val id: String, val version: Int) {
    *
    * To implement a new collector:
    * - Record events according to a "fus-collectors.md" dev guide and register it in plugin.xml
-   * - Implement custom validation rules if necessary (see SensitiveDataValidator)
+   * - Implement custom validation rules if necessary (see [com.intellij.internal.statistic.eventLog.validator.IntellijSensitiveDataValidator])
    * - If new group is implemented in a platform or a plugin built with IntelliJ Ultimate, YT issue will be created automatically
    * - Otherwise, create a YT issue in FUS project with group data scheme and descriptions to register it on the statistics metadata server
    *
index dbac460169c79bfe2bc9c6ecbccfd18aebb322a6..97d08d541e34dc725e427706dbfce0d329e9fc5d 100644 (file)
@@ -1,7 +1,7 @@
 // Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
 package com.intellij.internal.statistic.eventLog
 
-import com.intellij.internal.statistic.eventLog.validator.SensitiveDataValidator
+import com.intellij.internal.statistic.eventLog.validator.IntellijSensitiveDataValidator
 import com.intellij.internal.statistic.eventLog.validator.rules.impl.TestModeValidationRule
 import com.intellij.openapi.Disposable
 import com.intellij.openapi.util.Disposer
@@ -41,7 +41,7 @@ open class StatisticsFileEventLogger(private val recorderId: String,
     group.validateEventId(eventId)
     return try {
       CompletableFuture.runAsync(Runnable {
-        val validator = SensitiveDataValidator.getInstance(recorderId)
+        val validator = IntellijSensitiveDataValidator.getInstance(recorderId)
         if (!validator.isGroupAllowed(group)) return@Runnable
         val event = validator.validate(group.id, group.version.toString(), build, sessionId, bucket, eventTime, recorderVersion, eventId,
                                        data, isState)
similarity index 86%
rename from platform/statistics/src/com/intellij/internal/statistic/eventLog/validator/SensitiveDataValidator.java
rename to platform/statistics/src/com/intellij/internal/statistic/eventLog/validator/IntellijSensitiveDataValidator.java
index 25a5eccb81dafe33d82a4a1ce0e6442e4d696ec4..7fec2d431a5139b863548075138d4095671ca84f 100644 (file)
@@ -6,7 +6,7 @@ import com.intellij.internal.statistic.eventLog.FeatureUsageData;
 import com.intellij.internal.statistic.eventLog.validator.rules.EventContext;
 import com.intellij.internal.statistic.eventLog.validator.rules.beans.EventGroupRules;
 import com.intellij.internal.statistic.eventLog.validator.rules.impl.*;
-import com.intellij.internal.statistic.eventLog.validator.storage.ValidationRulesStorage;
+import com.intellij.internal.statistic.eventLog.validator.storage.IntellijValidationRulesStorage;
 import com.intellij.internal.statistic.eventLog.validator.storage.ValidationRulesStorageProvider;
 import com.intellij.internal.statistic.utils.PluginInfo;
 import com.intellij.openapi.application.ApplicationManager;
@@ -24,8 +24,7 @@ import static com.intellij.internal.statistic.utils.StatisticsUtilKt.addPluginIn
  * <p>
  *   The data from all collectors is validated before it's recorded locally.
  *   It's necessary to make sure that the data is correct and it doesn't contain personal or proprietary information.<br/>
- *   Validation is performed right before logging in {@link SensitiveDataValidator#guaranteeCorrectEventId(String, EventContext)}
- *   and {@link SensitiveDataValidator#guaranteeCorrectEventData(String, EventContext)}.<br/>
+ *   Validation is performed right before logging in {@link IntellijSensitiveDataValidator#validate}.<br/>
  * </p>
  *
  * <p>
@@ -97,38 +96,38 @@ import static com.intellij.internal.statistic.utils.StatisticsUtilKt.addPluginIn
  * </pre></li>
  * </ul>
  */
-public class SensitiveDataValidator extends SimpleSensitiveDataValidator<ValidationRulesStorage> {
-  private static final ConcurrentMap<String, SensitiveDataValidator> ourInstances = new ConcurrentHashMap<>();
+public class IntellijSensitiveDataValidator extends SensitiveDataValidator<IntellijValidationRulesStorage> {
+  private static final ConcurrentMap<String, IntellijSensitiveDataValidator> ourInstances = new ConcurrentHashMap<>();
 
   static {
     CustomValidationRule.EP_NAME.addChangeListener(ourInstances::clear, null);
     CustomWhiteListRule.EP_NAME.addChangeListener(ourInstances::clear, null);
   }
 
-  public static @NotNull SensitiveDataValidator getInstance(@NotNull String recorderId) {
+  public static @NotNull IntellijSensitiveDataValidator getInstance(@NotNull String recorderId) {
     return ourInstances.computeIfAbsent(
       recorderId,
       id -> {
-        ValidationRulesStorage storage = ValidationRulesStorageProvider.newStorage(recorderId);
+        IntellijValidationRulesStorage storage = ValidationRulesStorageProvider.newStorage(recorderId);
         return ApplicationManager.getApplication().isUnitTestMode()
                ? new BlindSensitiveDataValidator(storage)
-               : new SensitiveDataValidator(storage);
+               : new IntellijSensitiveDataValidator(storage);
       }
     );
   }
 
-  public static @Nullable SensitiveDataValidator getIfInitialized(@NotNull String recorderId) {
+  public static @Nullable IntellijSensitiveDataValidator getIfInitialized(@NotNull String recorderId) {
     return ourInstances.get(recorderId);
   }
 
-  protected SensitiveDataValidator(@NotNull ValidationRulesStorage storage) {
+  protected IntellijSensitiveDataValidator(@NotNull IntellijValidationRulesStorage storage) {
     super(storage);
   }
 
   public boolean isGroupAllowed(@NotNull EventLogGroup group) {
     if (TestModeValidationRule.isTestModeEnabled()) return true;
 
-    ValidationRulesStorage storage = getValidationRulesStorage();
+    IntellijValidationRulesStorage storage = getValidationRulesStorage();
     if (storage.isUnreachable()) return true;
     return storage.getGroupRules(group.getId()) != null;
   }
@@ -171,8 +170,8 @@ public class SensitiveDataValidator extends SimpleSensitiveDataValidator<Validat
     getValidationRulesStorage().reload();
   }
 
-  private static class BlindSensitiveDataValidator extends SensitiveDataValidator {
-    protected BlindSensitiveDataValidator(@NotNull ValidationRulesStorage storage) {
+  private static class BlindSensitiveDataValidator extends IntellijSensitiveDataValidator {
+    protected BlindSensitiveDataValidator(@NotNull IntellijValidationRulesStorage storage) {
       super(storage);
     }
 
index 02c146952a5844c08744bdb232887b3f3f691145..6ea41daa9a1337f848c07ad9c76fa70d2cbfaae9 100644 (file)
@@ -1,7 +1,7 @@
 // Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
 package com.intellij.internal.statistic.eventLog.validator.rules.impl;
 
-import com.intellij.internal.statistic.eventLog.validator.SensitiveDataValidator;
+import com.intellij.internal.statistic.eventLog.validator.IntellijSensitiveDataValidator;
 import com.intellij.internal.statistic.eventLog.validator.ValidationResultType;
 import com.intellij.internal.statistic.eventLog.validator.rules.EventContext;
 import com.intellij.internal.statistic.eventLog.validator.rules.FUSRule;
@@ -23,14 +23,14 @@ import org.jetbrains.annotations.Nullable;
  *   Base class for custom validation rules.
  *   If your data cannot be validated with enumerated values or by a regexp,
  *   inherit the class and implement {@link CustomValidationRule#doValidate(String, EventContext)}.
- *   For more information see {@link SensitiveDataValidator}.
+ *   For more information see {@link IntellijSensitiveDataValidator}.
  * </p>
  *
  * <p><i>Example:</i>
  * {@link com.intellij.internal.statistic.collectors.fus.ClassNameRuleValidator},
  * {@link com.intellij.internal.statistic.collectors.fus.LangCustomRuleValidator}, etc.</p>
  *
- * @see SensitiveDataValidator
+ * @see IntellijSensitiveDataValidator
  */
 public abstract class CustomValidationRule extends PerformanceCareRule implements FUSRule, UtilValidationRule {
   public static final ExtensionPointName<CustomValidationRule> EP_NAME =
index b40fc893fe15f7d74b5f01deeee7773e17f605bf..27079eae2cfea71f41a44406e75a51af6ec2533e 100644 (file)
@@ -5,13 +5,13 @@ import com.intellij.internal.statistic.eventLog.validator.rules.beans.EventGroup
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
-public class CompositeValidationRulesStorage implements ValidationRulesStorage, ValidationTestRulesStorageHolder {
+public class CompositeValidationRulesStorage implements IntellijValidationRulesStorage, ValidationTestRulesStorageHolder {
   @NotNull
-  private final ValidationRulesStorage myRulesStorage;
+  private final IntellijValidationRulesStorage myRulesStorage;
   @NotNull
   private final ValidationTestRulesPersistedStorage myTestRulesStorage;
 
-  CompositeValidationRulesStorage(@NotNull ValidationRulesStorage rulesStorage,
+  CompositeValidationRulesStorage(@NotNull IntellijValidationRulesStorage rulesStorage,
                                   @NotNull ValidationTestRulesPersistedStorage testRulesStorage) {
     myRulesStorage = rulesStorage;
     myTestRulesStorage = testRulesStorage;
@@ -2,13 +2,13 @@
 package com.intellij.internal.statistic.eventLog.validator.storage;
 
 import com.intellij.internal.statistic.eventLog.EventLogBuild;
-import com.intellij.internal.statistic.eventLog.validator.BaseValidationRuleStorage;
+import com.intellij.internal.statistic.eventLog.validator.ValidationRuleStorage;
 import com.intellij.internal.statistic.eventLog.validator.GroupValidators;
 import com.intellij.internal.statistic.eventLog.validator.rules.beans.EventGroupRules;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
-public interface ValidationRulesStorage extends BaseValidationRuleStorage<EventLogBuild> {
+public interface IntellijValidationRulesStorage extends ValidationRuleStorage<EventLogBuild> {
   @Nullable EventGroupRules getGroupRules(@NotNull String groupId);
 
   /**
index 4dc4be79bf31308ad79de01b964da4ed809a525a..057f630eaf19c96ff221998d602f58497a047657 100644 (file)
@@ -6,7 +6,7 @@ import com.intellij.internal.statistic.eventLog.validator.rules.beans.EventGroup
 /**
  * Thread unsafe
  */
-object ValidationRulesInMemoryStorage : ValidationRulesStorage {
+object ValidationRulesInMemoryStorage : IntellijValidationRulesStorage {
   val eventsValidators = HashMap<String, EventGroupRules>()
 
   override fun getGroupRules(groupId: String): EventGroupRules? = eventsValidators[groupId]
index 797c665e533e965c11ff323a3b5744113a2d4c1a..6562e899d130eaa466be1ccacf33cb9a674ca095 100644 (file)
@@ -23,7 +23,7 @@ import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.stream.Collectors;
 
-public class ValidationRulesPersistedStorage implements ValidationRulesStorage {
+public class ValidationRulesPersistedStorage implements IntellijValidationRulesStorage {
   private static final Logger LOG = Logger.getInstance(ValidationRulesPersistedStorage.class);
 
   protected final ConcurrentMap<String, EventGroupRules> eventsValidators = new ConcurrentHashMap<>();
index a2d40349e8539aaf058a9fb38e35e232325fd994..912a8003897859ab498d6317166fdada3ceee7db 100644 (file)
@@ -6,8 +6,8 @@ import org.jetbrains.annotations.NotNull;
 
 public final class ValidationRulesStorageProvider {
   @NotNull
-  public static ValidationRulesStorage newStorage(@NotNull String recorderId) {
-    final ValidationRulesStorage storage =
+  public static IntellijValidationRulesStorage newStorage(@NotNull String recorderId) {
+    final IntellijValidationRulesStorage storage =
       ApplicationManager.getApplication().isUnitTestMode() ? ValidationRulesInMemoryStorage.INSTANCE : new ValidationRulesPersistedStorage(recorderId);
     if (ApplicationManager.getApplication().isInternal()) {
       return new CompositeValidationRulesStorage(storage, new ValidationTestRulesPersistedStorage(recorderId));
index 59db09b84c7707a943845b497f32ebbb541ee399..1cfd58d16ec9b1303f64fa70954587dff393befc 100644 (file)
@@ -9,7 +9,7 @@ import com.intellij.internal.statistic.eventLog.StatisticsEventLoggerKt;
 import com.intellij.internal.statistic.eventLog.connection.metadata.EventGroupRemoteDescriptors;
 import com.intellij.internal.statistic.eventLog.connection.metadata.EventGroupRemoteDescriptors.EventGroupRemoteDescriptor;
 import com.intellij.internal.statistic.eventLog.connection.metadata.EventGroupRemoteDescriptors.GroupRemoteRule;
-import com.intellij.internal.statistic.eventLog.validator.SensitiveDataValidator;
+import com.intellij.internal.statistic.eventLog.validator.IntellijSensitiveDataValidator;
 import com.intellij.internal.statistic.eventLog.validator.rules.beans.EventGroupRules;
 import com.intellij.internal.statistic.eventLog.validator.storage.persistence.EventLogMetadataPersistence;
 import com.intellij.internal.statistic.eventLog.validator.storage.persistence.EventLogTestMetadataPersistence;
@@ -23,7 +23,7 @@ import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.stream.Collectors;
 
-public final class ValidationTestRulesPersistedStorage implements ValidationRulesStorage {
+public final class ValidationTestRulesPersistedStorage implements IntellijValidationRulesStorage {
   private final ConcurrentMap<String, EventGroupRules> eventsValidators = new ConcurrentHashMap<>();
   private final Object myLock = new Object();
   private final @NotNull EventLogTestMetadataPersistence myTestMetadataPersistence;
@@ -164,9 +164,9 @@ public final class ValidationTestRulesPersistedStorage implements ValidationRule
   }
 
   public static @Nullable ValidationTestRulesPersistedStorage getTestStorage(@NotNull String recorderId, boolean initIfNeeded) {
-    SensitiveDataValidator validator =
-      initIfNeeded ? SensitiveDataValidator.getInstance(recorderId) : SensitiveDataValidator.getIfInitialized(recorderId);
-    ValidationRulesStorage storage = validator != null ? validator.getValidationRulesStorage() : null;
+    IntellijSensitiveDataValidator validator =
+      initIfNeeded ? IntellijSensitiveDataValidator.getInstance(recorderId) : IntellijSensitiveDataValidator.getIfInitialized(recorderId);
+    IntellijValidationRulesStorage storage = validator != null ? validator.getValidationRulesStorage() : null;
     return storage instanceof ValidationTestRulesStorageHolder ? ((ValidationTestRulesStorageHolder)storage).getTestGroupStorage() : null;
   }
 
index f11e93a10c88b9da7f9684ef4b39c495db59a43f..38d2cfda983b75ee04577d7bb12dcc85dc9e0697 100644 (file)
@@ -3,7 +3,7 @@ package com.intellij.internal.statistic.service.fus.collectors;
 
 import com.intellij.internal.statistic.beans.MetricEvent;
 import com.intellij.internal.statistic.eventLog.FeatureUsageData;
-import com.intellij.internal.statistic.eventLog.validator.SensitiveDataValidator;
+import com.intellij.internal.statistic.eventLog.validator.IntellijSensitiveDataValidator;
 import com.intellij.openapi.extensions.ExtensionPointName;
 import org.jetbrains.annotations.ApiStatus;
 import org.jetbrains.annotations.NotNull;
@@ -19,7 +19,7 @@ import java.util.Set;
  * <ol>
  *   <li>Inherit the class, implement {@link ApplicationUsagesCollector#getGroup()} and {@link ApplicationUsagesCollector#getMetrics()} and register collector in plugin.xml.
  *   See <i>fus-collectors.md</i> for more details.</li>
- *   <li>Implement custom validation rules if necessary. For more information see {@link SensitiveDataValidator}.</li>
+ *   <li>Implement custom validation rules if necessary. For more information see {@link IntellijSensitiveDataValidator}.</li>
  *   <li>If new group is implemented in a platform or a plugin built with IntelliJ Ultimate, YT issue will be created automatically</li>
  *   <li>Otherwise, create a YT issue in FUS project with group data scheme and descriptions to register it on the statistics metadata server</li>
  * </ol>
index 9e183eba13442ffe82753283bba12459b97f4811..75c0a973e6aafec8b53ababbcd496ee3429a5375 100644 (file)
@@ -1,7 +1,7 @@
 // Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
 package com.intellij.internal.statistic.service.fus.collectors;
 
-import com.intellij.internal.statistic.eventLog.validator.SensitiveDataValidator;
+import com.intellij.internal.statistic.eventLog.validator.IntellijSensitiveDataValidator;
 
 /**
  * <p>Use it to create a collector which records user or internal IDE actions.</p>
@@ -10,7 +10,7 @@ import com.intellij.internal.statistic.eventLog.validator.SensitiveDataValidator
  * <ol>
  *   <li>Inherit the class, implement {@link CounterUsagesCollector#getGroup()}, register all events you want to record and register collector in plugin.xml.
  *   See <i>fus-collectors.md</i> for more details.</li>
- *   <li>Implement custom validation rules if necessary. For more information see {@link SensitiveDataValidator}.</li>
+ *   <li>Implement custom validation rules if necessary. For more information see {@link IntellijSensitiveDataValidator}.</li>
  *   <li>If new group is implemented in a platform or a plugin built with IntelliJ Ultimate, YT issue will be created automatically</li>
  *   <li>Otherwise, create a YT issue in FUS project with group data scheme and descriptions to register it on the statistics metadata server</li>
  * </ol>
index f91722c84ba431543723704fdda626d4d08cf652..0f9e102ec681237e3fdd21ba50ee73ab21930715 100644 (file)
@@ -3,7 +3,7 @@ package com.intellij.internal.statistic.service.fus.collectors;
 
 import com.intellij.internal.statistic.beans.MetricEvent;
 import com.intellij.internal.statistic.eventLog.FeatureUsageData;
-import com.intellij.internal.statistic.eventLog.validator.SensitiveDataValidator;
+import com.intellij.internal.statistic.eventLog.validator.IntellijSensitiveDataValidator;
 import com.intellij.openapi.application.ReadAction;
 import com.intellij.openapi.extensions.ExtensionPointName;
 import com.intellij.openapi.progress.ProgressIndicator;
@@ -25,7 +25,7 @@ import java.util.Set;
  * <ol>
  *   <li>Inherit the class, implement {@link ProjectUsagesCollector#getGroup()} and {@link ProjectUsagesCollector#getMetrics(Project)} and register collector in plugin.xml.
  *   See <i>fus-collectors.md</i> for more details.</li>
- *   <li>Implement custom validation rules if necessary. For more information see {@link SensitiveDataValidator}.</li>
+ *   <li>Implement custom validation rules if necessary. For more information see {@link IntellijSensitiveDataValidator}.</li>
  *   <li>If new group is implemented in a platform or a plugin built with IntelliJ Ultimate, YT issue will be created automatically</li>
  *   <li>Otherwise, create a YT issue in FUS project with group data scheme and descriptions to register it on the statistics metadata server</li>
  * </ol>
index 23aad512a2fac061a0ad4f5b08447c155671dfcf..d510fc05f17972f87538363b4b50ff9c2fff853a 100644 (file)
@@ -10,7 +10,7 @@ import com.intellij.internal.statistic.eventLog.StatisticsEventLoggerProvider;
 import com.intellij.internal.statistic.eventLog.connection.StatisticsService;
 import com.intellij.internal.statistic.eventLog.fus.FeatureUsageLogger;
 import com.intellij.internal.statistic.eventLog.uploader.EventLogExternalUploader;
-import com.intellij.internal.statistic.eventLog.validator.SensitiveDataValidator;
+import com.intellij.internal.statistic.eventLog.validator.IntellijSensitiveDataValidator;
 import com.intellij.internal.statistic.service.fus.collectors.FUStateUsagesLogger;
 import com.intellij.internal.statistic.utils.StatisticsUploadAssistant;
 import com.intellij.openapi.application.ApplicationManager;
@@ -71,7 +71,7 @@ final class StatisticsJobsScheduler implements ApplicationInitializedListener {
         final List<StatisticsEventLoggerProvider> providers = StatisticsEventLoggerKt.getEventLogProviders();
         for (StatisticsEventLoggerProvider provider : providers) {
           if (provider.isRecordEnabled()) {
-            SensitiveDataValidator.getInstance(provider.getRecorderId()).update();
+            IntellijSensitiveDataValidator.getInstance(provider.getRecorderId()).update();
           }
         }
       }, 3, 180, TimeUnit.MINUTES);
index 5e9c2039675f60c52cea864e846cc0ee4b8670f6..7c5970074cb38aed800d74de14c6371353e0f500 100644 (file)
@@ -5,7 +5,7 @@
 ```kotlin
 val validationRuleStorage = SimpleValidationRuleStorage("<bundled metadata>",
                                                         buildParser = { build: String? -> EventLogBuild.fromString(build) })
-val validator: SimpleSensitiveDataValidator<EventLogBuild> = SimpleSensitiveDataValidator(validationRuleStorage)
+val validator = SensitiveDataValidator(validationRuleStorage)
 
 val event: LogEvent = newLogEvent(session = "80bb576ed123",
                                   build = "203.6682.168",
@@ -16,7 +16,7 @@ val event: LogEvent = newLogEvent(session = "80bb576ed123",
                                   recorderVersion = "1",
                                   eventId = "eventId",
                                   isState = true,
-  eventData = hashMapOf("count" to 42))
+                                  eventData = hashMapOf("count" to 42))
 val validatedEvent: LogEvent? = validator.validateEvent(event)
 
 //…
@@ -10,9 +10,8 @@ import com.intellij.internal.statistic.eventLog.validator.rules.beans.EventGroup
 /**
  * Validates log event according to remote groups validation rules.
  * Used to ensure that no personal or proprietary data is recorded.
- *
  */
-open class SimpleSensitiveDataValidator<S: BaseValidationRuleStorage<*>>(public val validationRulesStorage: S) {
+open class SensitiveDataValidator<S: ValidationRuleStorage<*>>(val validationRulesStorage: S) {
   /**
    * @return null if the build or version failed validation,
    * otherwise returns validated event in which incorrect values are replaced with {@link ValidationResultType#getDescription()}.
index e858b56ae7764dd261b1415f732e74fc89e1b5fb..9f5629317492837ad61da29b7bbb104edbca70f3 100644 (file)
@@ -16,7 +16,7 @@ import com.intellij.internal.statistic.eventLog.validator.storage.GlobalRulesHol
 class SimpleValidationRuleStorage<T : Comparable<T>?>(initialMetadataContent: String,
                                                       private val buildParser: EventLogBuildParser<T>,
                                                       private val excludedFields: List<String> = emptyList(),
-                                                      utilRulesProducer: UtilRuleProducer = ValidationSimpleRuleFactory.REJECTING_UTIL_URL_PRODUCER) : BaseValidationRuleStorage<T> {
+                                                      utilRulesProducer: UtilRuleProducer = ValidationSimpleRuleFactory.REJECTING_UTIL_URL_PRODUCER) : ValidationRuleStorage<T> {
   private val validationRuleFactory = ValidationSimpleRuleFactory(utilRulesProducer)
   private val eventsValidators: MutableMap<String?, EventGroupRules> = HashMap() // guarded by lock
   private lateinit var filterRules: EventGroupsFilterRules<T> // guarded by lock
similarity index 83%
rename from platform/statistics/validator/src/com/intellij/internal/statistic/eventLog/validator/BaseValidationRuleStorage.kt
rename to platform/statistics/validator/src/com/intellij/internal/statistic/eventLog/validator/ValidationRuleStorage.kt
index 6e8f0ea35d189d61fb52f042389508b9b429799f..d7d34a0227a6de89b1acaf286f220a649bc47be5 100644 (file)
@@ -1,7 +1,7 @@
 // Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
 package com.intellij.internal.statistic.eventLog.validator
 
-interface BaseValidationRuleStorage<T : Comparable<T>?> {
+interface ValidationRuleStorage<T : Comparable<T>?> {
   fun getGroupValidators(groupId: String): GroupValidators<T>
   fun isUnreachable(): Boolean
 }
\ No newline at end of file