コード例 #1
0
ファイル: WMLCompositor.java プロジェクト: iwoj/Maui
 /**
  * This method creates an event vector based on a given request object.
  *
  * @param request The HttpRequest object.
  * @return A Vector containing the events
  */
 private Vector createEventVector(HTTPRequest request) {
   Vector eventVector = new Vector();
   if (request.getQueryValue("mauiEvent") != null) {
     eventVector = StringUtilities.split(".", request.getQueryValue("mauiEvent"));
   }
   return eventVector;
 }
コード例 #2
0
ファイル: WMLCompositor.java プロジェクト: iwoj/Maui
  /**
   * This method takes care of some special generic Maui events. It should be called before the Maui
   * application handles the event.
   *
   * @param mauiApp Reference to the MauiApplication associated with the events
   * @param eventVector The same event vector that is passed to the Maui app.
   * @param paramHash Hashtable of HTTP parameters
   * @param response The HTTPResponse object which will be sent back to the client
   */
  private void processEvent(
      MauiApplication mauiApp,
      Vector eventVector,
      Hashtable paramHash,
      HTTPRequest request,
      HTTPResponse response) {
    boolean passEventToMauiApp = true;

    try {
      if (eventVector != null && !eventVector.isEmpty()) {
        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        // Component events
        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        String componentID = (String) eventVector.lastElement();

        // If there are parentheses...
        if (componentID.startsWith("(") && componentID.endsWith(")")) {
          // ... strip them off!
          componentID = componentID.substring(1, componentID.length() - 1);
        }

        //
        //	Strip off prefix - some wml browsers don't like variables that begin with a digit
        //
        if (componentID.startsWith("IDz")) {
          componentID = componentID.substring(3);
        }
        {
          System.err.println("componentID: " + componentID);
        }

        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        // Pass events to Maui application
        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        // Check for a content-type override
        String contentType = null;
        {
          if ((contentType = request.getQueryValue("contentType")) != null) {
            response.setContentType(contentType);
          } else {
            response.setContentType("x-wap.wml");
          }
        }
        response.setContent(mauiApp.render().getBytes());
      } else {
        response.setContentType("text/vnd.wap.wml");
        response.setContent(mauiApp.render().getBytes());
      }
    } catch (Exception e) {
      response.setContentType(getBaseContentType());
      response.setContent((generateExceptionMessage(e)).getBytes());
      e.printStackTrace(System.err);
    }
  }
コード例 #3
0
  public String postFile(URLFetchService us, List<PostObj> postobjlist) throws Exception {
    int index;

    Gson gson;
    String linkID;
    List<String> linkList;
    HTTPRequest req;
    String param;

    gson = new Gson();

    linkID = createUID();
    linkList = new ArrayList<String>();
    for (index = 0; index < postobjlist.size(); index++) {
      linkList.add(postobjlist.get(index).filelink);
    }

    param =
        URLEncoder.encode("postlist", "UTF-8")
            + "="
            + URLEncoder.encode(gson.toJson(postobjlist), "UTF-8")
            + '&'
            + URLEncoder.encode("linkid", "UTF-8")
            + "="
            + URLEncoder.encode(linkID, "UTF-8")
            + '&'
            + URLEncoder.encode("linklist", "UTF-8")
            + "="
            + URLEncoder.encode(gson.toJson(linkList), "UTF-8");
    req =
        new HTTPRequest(
            new URL("http://tnfshmoe.appspot.com/postdf89ksfxsyx9sfdex09usdjksd"), HTTPMethod.POST);
    req.setPayload(param.getBytes());
    us.fetch(req);

    return linkID;
  }
コード例 #4
0
ファイル: WMLCompositor.java プロジェクト: iwoj/Maui
 /**
  * This method creates a parameter hashtables based on a given request object.
  *
  * @param request The HttpServletRequest object.
  * @return A Hashtable containing the HTTP parameter key/value pairs
  */
 private Hashtable createParamHash(HTTPRequest request) {
   return request.getQueries();
 }
コード例 #5
0
 public void set(HTTPRequest httpReq) {
   set((HTTPPacket) httpReq);
   setSocket(httpReq.getSocket());
 }