Examples of TwistInfo


Examples of com.mockey.model.TwistInfo

      JSONObject responseObject = new JSONObject();
      JSONObject messageObject = new JSONObject();
      messageObject.put("proxy_enabled", Boolean.toString(proxyInfo.isProxyEnabled()));
      messageObject.put("transient_state", store.getReadOnlyMode());
      Long twistInfoId = store.getUniversalTwistInfoId();
      TwistInfo twistInfo = store.getTwistInfoById(twistInfoId);
      if (twistInfo != null) {
        messageObject.put("twist_enabled", true);
        messageObject.put("twist-id", twistInfo.getId());
        messageObject.put("twist-name", twistInfo.getName());

      } else {
        messageObject.put("twist_enabled", false);
      }
      String filter = (String)req.getSession().getAttribute(TagHelperServlet.FILTER_TAG);
View Full Code Here

Examples of com.mockey.model.TwistInfo

    String responseType = req.getParameter("response-type");
    // If type is JSON, then respond with JSON
    // Otherwise, direct to JSP

    Long twistInfoId = null;
    TwistInfo twistInfo = null;
    try {
      twistInfoId = new Long(req.getParameter(PARAMETER_KEY_TWIST_ID));
      twistInfo = store.getTwistInfoById(twistInfoId);
      store.deleteTwistInfo(twistInfo);
    } catch (Exception e) {
View Full Code Here

Examples of com.mockey.model.TwistInfo

    String responseType = req.getParameter("response-type");
    // If type is JSON, then respond with JSON
    // Otherwise, direct to JSP

    Long twistInfoId = null;
    TwistInfo twistInfo = null;
    String coachingMessage = null;
    JSONObject jsonObject = new JSONObject();

    try {
      twistInfoId = new Long(req.getParameter(PARAMETER_KEY_TWIST_ID));
      boolean enable = Boolean.parseBoolean(req.getParameter(PARAMETER_KEY_TWIST_ENABLE));
      twistInfo = store.getTwistInfoById(twistInfoId);
      if(enable){
        store.setUniversalTwistInfoId(twistInfo.getId());
        if (twistInfo != null) {
          jsonObject.put(PARAMETER_KEY_TWIST_ID, "" + twistInfo.getId());
          jsonObject.put(PARAMETER_KEY_TWIST_NAME, "" + twistInfo.getName());
          coachingMessage = "Twist configuration on";
        }
       
      }else if(store.getUniversalTwistInfoId()!=null && store.getUniversalTwistInfoId().equals(twistInfoId)){
        // Disable
View Full Code Here

Examples of com.mockey.model.TwistInfo

    // ***********************
    // INITIALIZAION
    // ***********************

    Long twistInfoId = null;
    TwistInfo twistInfo = null;
    try {
      twistInfoId = new Long(req.getParameter(PARAMETER_KEY_TWIST_ID));
      twistInfo = store.getTwistInfoById(twistInfoId);
    } catch (Exception e) {
      // Do nothing. If the value doesn't exist,
      // then we'll create a new TwistInfo
    }

    if (twistInfo == null) {
      twistInfo = new TwistInfo();
    }
    // ***********************
    // DATA HANDLING
    // ***********************
    String name = req.getParameter(PARAMETER_KEY_TWIST_NAME);
   
    if (name == null || name.trim().length() == 0) {
      name = "TwistInfo (auto-generated)";
    }
    String[] originationArguments = req.getParameterValues(PARAMETER_KEY_TWIST_ORIGINATION_LIST);
    String[] destinationArguments = req.getParameterValues(PARAMETER_KEY_TWIST_DESTINATION_LIST);
    // Remove any existing TwistInfo patterns.
    twistInfo.setPatternPairList(new ArrayList<PatternPair>());
    if ((originationArguments != null && destinationArguments != null)
        && (originationArguments.length == destinationArguments.length)) {
      for (int i = 0; i < originationArguments.length; i++) {
        twistInfo.addPatternPair(new PatternPair(originationArguments[i], destinationArguments[i]));
      }
    }

    twistInfo.setName(name);
    twistInfo = store.saveOrUpdateTwistInfo(twistInfo);
   
    // ***********************
    // RESPONSE - in JSON or JSP
    // ***********************
    String responseType = req.getParameter(PARAMETER_KEY_RESPONSE_TYPE);
    if (PARAMETER_KEY_RESPONSE_TYPE_VALUE_JSON.equalsIgnoreCase(responseType)) {
      // BUILD JSON response
      resp.setContentType("application/json");
      PrintWriter out = resp.getWriter();
      try {
        JSONObject jsonResponseObject = new JSONObject();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("success", "Twist updated");
        jsonObject.put("id", ""+twistInfo.getId());
        jsonObject.put("name", twistInfo.getName());

        jsonResponseObject.put("result", jsonObject);
        out.println(jsonResponseObject.toString());

      } catch (JSONException jsonException) {
View Full Code Here

Examples of com.mockey.model.TwistInfo

    // ************************************************************************
    // STEP #1) Is URL TWISTING ON?
    // ************************************************************************
    targetHttpReqURI = originalHttpReqURI;
    if (store.getUniversalTwistInfoId() != null) {
      TwistInfo twistInfo = store.getTwistInfoById(store.getUniversalTwistInfoId());
      if (twistInfo != null) {
        logger.debug("URL twisting is enabled.");
        targetHttpReqURI = twistInfo.getTwistedValue(originalHttpReqURI);
      }
    }

    Url serviceUrl = new Url(targetHttpReqURI);
    Service service = store.getServiceByUrl(serviceUrl.getFullUrl());
View Full Code Here

Examples of com.mockey.model.TwistInfo

  public TwistInfo getTwistInfoById(Long id) {
    return (TwistInfo) this.twistInfoStore.get(id);
  }

  public TwistInfo getTwistInfoByName(String name) {
    TwistInfo item = null;
    for (TwistInfo i : getTwistInfoList()) {
      if (i.getName() != null && i.getName().equals(name)) {
        item = i;
        break;
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.