private void readExternal()

in usage-statistics-util/src/jetbrains/buildServer/usageStatistics/impl/providers/BaseToolUsersUsageStatisticsProvider.java [164:196]


  private void readExternal(@NotNull final Element element) {
    myLock.writeLock().lock();
    try {
      final long threshold = getThresholdDate();
      myToolUsages.clear();
      for (final Object tool : element.getChildren(getToolName())) {
        if (!(tool instanceof Element)) continue;
        final Element toolElement = (Element)tool;
        final String toolIdSource = toolElement.getAttributeValue(getToolIdName());
        if (toolIdSource == null) continue;
        final Map<Long, Long> value = new ConcurrentHashMap<>();
        myToolUsages.put(toolIdSource, value);
        for (final Object usage : toolElement.getChildren(USAGE)) {
          if (!(usage instanceof Element)) continue;
          final Element usageElement = (Element)usage;
          final String userIdStr = usageElement.getAttributeValue(USER_ID);
          if (userIdStr == null) continue;
          final String timestampStr = usageElement.getAttributeValue(TIMESTAMP);
          if (timestampStr == null) continue;
          try {
            long timestamp = Long.parseLong(timestampStr);
            if (timestamp > threshold) {
              long userId = Long.parseLong(userIdStr);
              value.put(userId, timestamp);
            }
          } catch (final NumberFormatException ignored) {
          }
        }
      }
    } finally {
      myLock.writeLock().unlock();
    }
  }