Пример #1
0
 public List<LogType> getPossibleLogTypes() {
   boolean isOwner = owner != null && owner.equalsIgnoreCase(Settings.getUsername());
   List<LogType> logTypes = new ArrayList<LogType>();
   if (isEventCache()) {
     logTypes.add(LogType.LOG_WILL_ATTEND);
     logTypes.add(LogType.LOG_NOTE);
     logTypes.add(LogType.LOG_ATTENDED);
     logTypes.add(LogType.LOG_NEEDS_ARCHIVE);
     if (isOwner) {
       logTypes.add(LogType.LOG_ANNOUNCEMENT);
     }
   } else if (CacheType.WEBCAM == cacheType) {
     logTypes.add(LogType.LOG_WEBCAM_PHOTO_TAKEN);
     logTypes.add(LogType.LOG_DIDNT_FIND_IT);
     logTypes.add(LogType.LOG_NOTE);
     logTypes.add(LogType.LOG_NEEDS_ARCHIVE);
     logTypes.add(LogType.LOG_NEEDS_MAINTENANCE);
   } else {
     logTypes.add(LogType.LOG_FOUND_IT);
     logTypes.add(LogType.LOG_DIDNT_FIND_IT);
     logTypes.add(LogType.LOG_NOTE);
     logTypes.add(LogType.LOG_NEEDS_ARCHIVE);
     logTypes.add(LogType.LOG_NEEDS_MAINTENANCE);
   }
   if (isOwner) {
     logTypes.add(LogType.LOG_OWNER_MAINTENANCE);
     logTypes.add(LogType.LOG_TEMP_DISABLE_LISTING);
     logTypes.add(LogType.LOG_ENABLE_LISTING);
     logTypes.add(LogType.LOG_ARCHIVE);
     logTypes.remove(LogType.LOG_UPDATE_COORDINATES);
   }
   return logTypes;
 }
 /** Test cache parsing. Esp. useful after a GC.com update */
 public static void testSearchByGeocodeBasis() {
   for (MockedCache mockedCache : RegExPerformanceTest.MOCKED_CACHES) {
     mockedCache.setMockedDataUser(Settings.getUsername());
     cgCache parsedCache = cgeoApplicationTest.testSearchByGeocode(mockedCache.getGeocode());
     if (null != parsedCache) {
       cgBaseTest.testCompareCaches(mockedCache, parsedCache);
     }
   }
 }
 private Message createMessage() {
   dbHelper.open();
   Message message =
       dbHelper.createMessage(
           settings.getUsername(),
           content.getText().toString(),
           Calendar.getInstance().getTimeInMillis());
   TransportConfiguration tc = new TransportConfiguration();
   dbHelper.close();
   return message;
 }
Пример #4
0
  /**
   * Initializes the {@link #settings} object from a settings.properties file taken from the root of
   * the class path Without this being successful many or all integration tests will fail.
   *
   * @throws IOException if settings.properties cannot be loaded
   * @throws IllegalAccessException if an attempt is made to access a field that doesn't
   *     exist...shouldn't happen
   */
  @Before
  public void setup() throws IOException, IllegalAccessException, Exception {
    InputStream in = IntegrationTestBase.class.getResourceAsStream("/settings.properties");
    Properties properties = new Properties();
    properties.load(in);
    Class<Settings> klass = Settings.class;

    for (String name : properties.stringPropertyNames()) {
      try {
        Field field = klass.getDeclaredField(name);
        field.setAccessible(true);

        Object value = properties.getProperty(name);

        if (field.getType().isAssignableFrom(int.class)
            || field.getType().isAssignableFrom(Integer.class)) {
          value = Integer.parseInt(String.valueOf(value));
        }

        if (field.getType().isAssignableFrom(boolean.class)
            || field.getType().isAssignableFrom(Boolean.class)) {
          value = Integer.parseInt(String.valueOf(value));
        }

        field.set(settings, value);
      } catch (NoSuchFieldException e) {
        e.printStackTrace();
        log.warn(
            String.format("Unknown setting. '%s' doesn't match a known setting,ignored", name));
      }
    }
    config.host("127.0.0.1");
    config
        .urlEncodingFormat(settings.getUrlEncodeWith())
        .auth(settings.getUsername(), settings.getApiKey());
    datasift = new DataSiftClient(config);
  }
  public StatusCode postLogFn(String log) {
    try {
      final StatusCode status =
          cgBase.postLog(
              geocode,
              cacheid,
              viewstates,
              typeSelected,
              date.get(Calendar.YEAR),
              (date.get(Calendar.MONTH) + 1),
              date.get(Calendar.DATE),
              log,
              trackables);

      if (status == StatusCode.NO_ERROR) {
        final cgLog logNow = new cgLog();
        logNow.author = Settings.getUsername();
        logNow.date = date.getTimeInMillis();
        logNow.type = typeSelected;
        logNow.log = log;

        if (cache != null) {
          cache.prependLog(logNow);
        }
        app.addLog(geocode, logNow);

        if (typeSelected == LogType.LOG_FOUND_IT) {
          app.markFound(geocode);
          if (cache != null) {
            cache.setFound(true);
          }
        }

        if (cache != null) {
          app.saveCache(cache, EnumSet.of(SaveFlag.SAVE_CACHE));
        } else {
          app.removeCache(geocode, EnumSet.of(RemoveFlag.REMOVE_CACHE));
        }
      }

      if (status == StatusCode.NO_ERROR) {
        app.clearLogOffline(geocode);
      }

      if (status == StatusCode.NO_ERROR
          && typeSelected == LogType.LOG_FOUND_IT
          && Settings.isUseTwitter()
          && Settings.isTwitterLoginValid()
          && tweetCheck.isChecked()
          && tweetBox.getVisibility() == View.VISIBLE) {
        Twitter.postTweetCache(geocode);
      }

      if (status == StatusCode.NO_ERROR
          && typeSelected == LogType.LOG_FOUND_IT
          && Settings.isGCvoteLogin()) {
        GCVote.setRating(cache, rating);
      }

      return status;
    } catch (Exception e) {
      Log.e("cgeovisit.postLogFn: " + e.toString());
    }

    return StatusCode.LOG_POST_ERROR;
  }