예제 #1
0
  /**
   * @param aReq
   * @param aResp
   * @throws ServletException
   * @throws IOException
   */
  @Override
  protected void doPost(HttpServletRequest aReq, HttpServletResponse aResp)
      throws ServletException, IOException {
    String lAction = aReq.getParameter("action");
    String lSessionId = getSessionId(aReq);
    String lConnectorId = getConnectorId(aReq, lSessionId);
    if (null == lConnectorId) {
      sendMessage(400, "Missing 'connectionId' parameter value!", aResp);
      return;
    }

    if (!mConnectorsManager.connectorExists(lConnectorId)) {
      sendMessage(411, "Invalid connection state!", aResp);
      return;
    }

    if ("send".equals(lAction)) {
      processSend(lConnectorId, aReq, aResp);
    } else {
      sendMessage(404, "Invalid request!", aResp);
    }

    // session management
    updateSessionTimeout(lSessionId);
  }
예제 #2
0
  /**
   * @param aReq
   * @param aResp
   * @throws ServletException
   * @throws IOException
   */
  @Override
  protected void doGet(HttpServletRequest aReq, HttpServletResponse aResp)
      throws ServletException, IOException {
    String lAction = aReq.getParameter("action");
    String lSessionId = getSessionId(aReq);
    String lConnectorId = getConnectorId(aReq, lSessionId);
    if (null == lConnectorId) {
      sendMessage(400, "Missing 'connectionId' parameter value!", aResp);
      return;
    }

    if ("sync".equals(lAction)) {
      processSync(lConnectorId, aReq, aResp);
    } else if ("open".equals(lAction)) {
      if (mConnectorsManager.connectorExists(lConnectorId)) {
        sendMessage(400, "Invalid connection state!", aResp);
        return;
      }

      processOpen(lSessionId, lConnectorId, aReq, aResp);
    } else {
      if (!mConnectorsManager.connectorExists(lConnectorId)) {
        sendMessage(400, "Invalid connection state!", aResp);
        return;
      }

      if ("login".equals(lAction)) {
        processLogin(lConnectorId, aReq, aResp);
      } else if ("logout".equals(lAction)) {
        processLogout(lConnectorId, aReq, aResp);
      } else if ("send".equals(lAction)) {
        processSend(lConnectorId, aReq, aResp);
      } else if ("download".equals(lAction)) {
        processDownload(lConnectorId, aReq, aResp);
      } else if ("close".equals(lAction)) {
        processClose(lConnectorId, aReq, aResp);
      } else {
        sendMessage(404, "Invalid request!", aResp);
      }
    }

    // session management
    updateSessionTimeout(lSessionId);
  }