Пример #1
0
  public static Long getLongValue(AVList avList, String key) {
    Object o = avList.getValue(key);
    if (o == null) return null;

    if (o instanceof Long) return (Long) o;

    String v = getStringValue(avList, key);
    if (v == null) return null;

    try {
      return Long.parseLong(v);
    } catch (NumberFormatException e) {
      Logging.logger().log(Level.SEVERE, "Configuration.ConversionError", v);
      return null;
    }
  }
  public Long getLayerLatestLastUpdateTime(WMSCapabilities caps, String[] layerNames) {
    if (caps == null) {
      String message = Logging.getMessage("nullValue.WMSCapabilities");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    if (layerNames == null) {
      String message = Logging.getMessage("nullValue.WMSLayerNames");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    String lastUpdate = null;

    for (String name : layerNames) {
      WMSLayerCapabilities layer = this.getLayerByName(name);
      if (layer == null) continue;

      String update = layer.getLastUpdate();
      if (update != null
          && update.length() > 0
          && (lastUpdate == null || update.compareTo(lastUpdate) > 0)) lastUpdate = update;
    }

    if (lastUpdate != null) {
      try {
        return Long.parseLong(lastUpdate);
      } catch (NumberFormatException e) {
        String message = Logging.getMessage("generic.ConversionError", lastUpdate);
        Logging.logger().warning(message);
      }
    }

    return null;
  }