// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementsConfig.java
// public class AchievementsConfig {
//   private final List<Achievement> myAchievements;
// 
//   public AchievementsConfig(@NotNull Collection<Achievement> achievements) {
//     myAchievements = new ArrayList<Achievement>(achievements);
//     Collections.sort(myAchievements, new Comparator<Achievement>() {
//       public int compare(Achievement o1, Achievement o2) {
//         return o1.getName().compareToIgnoreCase(o2.getName());
//       }
//     });
//   }
// 
//   @NotNull
//   public List<Achievement> getAchievements() {
//     return Collections.unmodifiableList(myAchievements);
//   }
// 
//   @NotNull
//   public Map<String, Achievement> getAchievementsMap() {
//     Map<String, Achievement> res = new HashMap<String, Achievement>();
//     for (Achievement a: myAchievements) {
//       res.put(a.getId(), a);
//     }
//     return res;
//   }
// 
// }
// 
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
//   void registerEvent(@NotNull String eventName);
// 
//   void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
// 
//   long getLastEventTime(@NotNull String eventName);
// 
//   // most recent first
//   @NotNull
//   List<Long> getEventTimes(@NotNull String eventName);
// 
//   int getNumberOfEvents(@NotNull String eventName);
// 
//   float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
// 
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsListener.java
// public interface UserEventsListener extends EventListener {
//   void userEventPublished(@NotNull User user, @NotNull String eventName, @Nullable Object additionalData);
// }
// 
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsRegistry.java
// public interface UserEventsRegistry {
//   @NotNull
//   UserEvents getUserEvents(@NotNull User user);
// 
//   void addListener(@NotNull UserEventsListener listener);
// 
//   void removeListener(@NotNull UserEventsListener listener);
// }


import com.intellij.openapi.diagnostic.Logger;
import jetbrains.buildServer.serverSide.SecurityContextEx;
import jetbrains.buildServer.serverSide.impl.LogUtil;
import jetbrains.buildServer.users.*;
import jetbrains.buildServer.util.ExceptionUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementsConfig;
import org.jetbrains.buildserver.achievements.UserEvents;
import org.jetbrains.buildserver.achievements.UserEventsListener;
import org.jetbrains.buildserver.achievements.UserEventsRegistry;
import java.util.*;
/*
 * Copyright 2000-2021 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.jetbrains.buildserver.achievements.impl;



public class AchievementsGrantor implements UserEventsListener {
  private final static Logger LOG = Logger.getInstance(AchievementsGrantor.class.getName());

// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementsConfig.java
// public class AchievementsConfig {
//   private final List<Achievement> myAchievements;
// 
//   public AchievementsConfig(@NotNull Collection<Achievement> achievements) {
//     myAchievements = new ArrayList<Achievement>(achievements);
//     Collections.sort(myAchievements, new Comparator<Achievement>() {
//       public int compare(Achievement o1, Achievement o2) {
//         return o1.getName().compareToIgnoreCase(o2.getName());
//       }
//     });
//   }
// 
//   @NotNull
//   public List<Achievement> getAchievements() {
//     return Collections.unmodifiableList(myAchievements);
//   }
// 
//   @NotNull
//   public Map<String, Achievement> getAchievementsMap() {
//     Map<String, Achievement> res = new HashMap<String, Achievement>();
//     for (Achievement a: myAchievements) {
//       res.put(a.getId(), a);
//     }
//     return res;
//   }
// 
// }
// 
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
//   void registerEvent(@NotNull String eventName);
// 
//   void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
// 
//   long getLastEventTime(@NotNull String eventName);
// 
//   // most recent first
//   @NotNull
//   List<Long> getEventTimes(@NotNull String eventName);
// 
//   int getNumberOfEvents(@NotNull String eventName);
// 
//   float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
// 
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsListener.java
// public interface UserEventsListener extends EventListener {
//   void userEventPublished(@NotNull User user, @NotNull String eventName, @Nullable Object additionalData);
// }
// 
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsRegistry.java
// public interface UserEventsRegistry {
//   @NotNull
//   UserEvents getUserEvents(@NotNull User user);
// 
//   void addListener(@NotNull UserEventsListener listener);
// 
//   void removeListener(@NotNull UserEventsListener listener);
// }


// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/AchievementsGrantor.java
import com.intellij.openapi.diagnostic.Logger;
import jetbrains.buildServer.serverSide.SecurityContextEx;
import jetbrains.buildServer.serverSide.impl.LogUtil;
import jetbrains.buildServer.users.*;
import jetbrains.buildServer.util.ExceptionUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementsConfig;
import org.jetbrains.buildserver.achievements.UserEvents;
import org.jetbrains.buildserver.achievements.UserEventsListener;
import org.jetbrains.buildserver.achievements.UserEventsRegistry;
import java.util.*;

/*
 * Copyright 2000-2021 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.jetbrains.buildserver.achievements.impl;



public class AchievementsGrantor implements UserEventsListener {
  private final static Logger LOG = Logger.getInstance(AchievementsGrantor.class.getName());

  private final AchievementsConfig myConfig;