Esempio n. 1
0
  public static Result start() {
    java.util.Map<String, String[]> map = request().body().asFormUrlEncoded();

    List<String> terms = new ArrayList<>(map.size());
    for (int i = 0; i < map.size(); i++) {
      String key = "terms[" + i + "]";
      if (map.containsKey(key)) {
        String[] values = map.get(key);
        if ((values != null) && (values.length >= 1)) {
          terms.add(values[0]);
        }
      }
    }

    StreamConfig config = getConfig();
    config.putTerms(terms);
    config.update();

    StringBuilder sb = new StringBuilder();
    for (String t : terms) {
      sb.append(t);
      sb.append(", ");
    }
    sb.delete(sb.length() - 2, sb.length());

    try {
      startStream(terms);
      flash("success", "Twitter stream started (" + sb.toString() + ")");
    } catch (TwitterException e) {
      Logger.info("Error starting twitter stream", e);
      flash("error", "Error starting Twitter stream" + e.getMessage());
    }
    return redirect(routes.Streams.listAll());
  }
 @SuppressWarnings("unchecked")
 public void setRenderArgs(java.util.Map<String, Object> args) {
   if (null != args && args.containsKey("type")) this.type = (String) args.get("type");
   if (null != args && args.containsKey("flash"))
     this.flash = (play.mvc.Scope.Flash) args.get("flash");
   if (null != args && args.containsKey("error_index"))
     this.error_index = (Integer) args.get("error_index");
   if (null != args && args.containsKey("error"))
     this.error = (play.data.validation.Error) args.get("error");
   if (null != args && args.containsKey("params"))
     this.params = (play.mvc.Scope.Params) args.get("params");
   if (null != args && args.containsKey("lang")) this.lang = (java.lang.String) args.get("lang");
   if (null != args && args.containsKey("messages"))
     this.messages = (play.i18n.Messages) args.get("messages");
   if (null != args && args.containsKey("error_isFirst"))
     this.error_isFirst = (Boolean) args.get("error_isFirst");
   if (null != args && args.containsKey("errors"))
     this.errors = (java.util.List<play.data.validation.Error>) args.get("errors");
   if (null != args && args.containsKey("error_isLast"))
     this.error_isLast = (Boolean) args.get("error_isLast");
   if (null != args && args.containsKey("session"))
     this.session = (play.mvc.Scope.Session) args.get("session");
   if (null != args && args.containsKey("request"))
     this.request = (play.mvc.Http.Request) args.get("request");
   if (null != args && args.containsKey("_rythmPlugin"))
     this._rythmPlugin = (com.greenlaw110.rythm.play.RythmPlugin) args.get("_rythmPlugin");
   if (null != args && args.containsKey("_response_encoding"))
     this._response_encoding = (java.lang.String) args.get("_response_encoding");
   if (null != args && args.containsKey("_renderArgs"))
     this._renderArgs = (play.mvc.Scope.RenderArgs) args.get("_renderArgs");
   if (null != args && args.containsKey("_rythm"))
     this._rythm = (com.greenlaw110.rythm.RythmEngine) args.get("_rythm");
   if (null != args && args.containsKey("error_parity"))
     this.error_parity = (java.lang.String) args.get("error_parity");
   if (null != args && args.containsKey("_play")) this._play = (play.Play) args.get("_play");
   super.setRenderArgs(args);
 }