Package com.mockey.model

Examples of com.mockey.model.Url


    // w/ the same non-empty real URL.
    try {

      for (Service testService : store.getServices()) {

        Url firstMatch = testService.getFirstMatchingRealServiceUrl(ms);
        if (firstMatch != null && !testService.getId().equals(ms.getId())) {

          errorMap.put("serviceUrlMsg", "One of your Real service URL entries is already managed by the '"
              + testService.getServiceName() + "' service. Please choose another real URL pattern. ");
          errorMap.put("serviceUrl", firstMatch.getFullUrl());
          break;
        } else if (testService.getUrl() != null && ms.getUrl() != null) {
          if (testService.getUrl().trim().equalsIgnoreCase(ms.getUrl().trim())
              && !testService.getId().equals(ms.getId())) {
View Full Code Here


        .getFulfilledClientRequestsById(fulfilledClientRequestId);
    String pipeDelimitedHeaderInfo = req.getParameter("requestHeader");
    String parameters = req.getParameter("requestParameters");
    String body = req.getParameter("requestBody");

    Url serviceUrl = new Url(pastFulfilledClientRequest.getRawRequest());
    StringBuffer redoUrl = new StringBuffer();

    // 1. Cut out the parameters
    String fullUrl = serviceUrl.getFullUrl();
    int indexOfParam = fullUrl.indexOf("?");
    if (indexOfParam > 0) {
      fullUrl = fullUrl.substring(0, indexOfParam);
    }
    redoUrl.append("/service/" + fullUrl);
View Full Code Here

        logger.debug("URL twisting is enabled.");
        targetHttpReqURI = twistInfo.getTwistedValue(originalHttpReqURI);
      }
    }

    Url serviceUrl = new Url(targetHttpReqURI);
    Service service = store.getServiceByUrl(serviceUrl.getFullUrl());
    // ************************************************************************
    // STEP #2) Process your original request.
    // ************************************************************************
    RequestFromClient request = new RequestFromClient(originalHttpReqFromClient);

    // ************************************************************************
    // STEP #3) JAVA and JSON implemented Inspectors
    // ************************************************************************

    PluginStore pluginStore = PluginStore.getInstance();
    RequestInspectionResult inspectionMessage = pluginStore.processRequestInspectors(service, request);

    // ************************************************************************
    // STEP #4) Get the Response (static,dynamic, or proxy).
    // ************************************************************************
    service.setHttpMethod(originalHttpReqFromClient.getMethod());
    ResponseFromService response = service.execute(request, serviceUrl);

    // ************************************************************************
    // STEP #5) If twisting was enabled, let's be sure to set the original URL
    // ************************************************************************
    if (!originalHttpReqURI.equalsIgnoreCase(targetHttpReqURI)) {
      response.setOriginalRequestUrlBeforeTwisting(new Url(originalHttpReqURI));
    }
    logRequestAsFulfilled(service, request, response, originalHttpReqFromClient.getRemoteAddr(), inspectionMessage);

    try {
      // Wait for a X hang time seconds.
View Full Code Here

      logger.debug("Didn't find service with Service path: " + url + ".  Creating a new one.");
    }

    service = new Service();
    try {
      Url newUrl = new Url(Url.getSchemeHostPortPathFromURL(url));
      service.setUrl(newUrl.getFullUrl());
      service.saveOrUpdateRealServiceUrl(newUrl);
      store.saveOrUpdateService(service);

    } catch (MalformedURLException e) {
      logger.error("Unable to build a Service with URL '" + url + "'", e);
View Full Code Here

   * @param serviceToEvaluate
   *            service state to compare to the url
   * @return service if url pattern matches
   */
  private Service findServiceBasedOnUrlPattern(String url, Service serviceToEvaluate) {
    Url fullUrl = new Url(serviceToEvaluate.getUrl());
    Service foundService = null;
    // EXAMPLE: "http://example.com/hotels/{hotel}/bookings/{booking}"
    UriTemplate template = new UriTemplate(fullUrl.getFullUrl());

    // EXAMPLE: "http://example.com/hotels/1/bookings/42"
    @SuppressWarnings("rawtypes")
    Map results = template.match(url);
    if (results.size() > 0) {
      // Possible match
      foundService = serviceToEvaluate;
    } else {

      // OK, not found based on template URL.
      if (fullUrl.getFullUrl().equalsIgnoreCase(url)) {
        foundService = serviceToEvaluate;
      } else {
        // Let's look at secondary list of real URLs
        List<Url> serviceUrlList = serviceToEvaluate.getRealServiceUrls();
        Iterator<Url> altUrlIter = serviceUrlList.iterator();
        while (altUrlIter.hasNext()) {
          Url altUrl = altUrlIter.next();

          // Variable template is set to the template of the service's
          // full URL.
          // The template is matched against the service real URLs,
          // therefore the match always succeeds. The template should
          // be
          // matched against the url of the request instead.
          template = new UriTemplate(altUrl.getFullUrl());
          results = template.match(url);

          if (results.size() > 0) {
            // Possible match
            foundService = serviceToEvaluate;
View Full Code Here

TOP

Related Classes of com.mockey.model.Url

Copyright © 2018 www.massapicom. 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.