Examples of ERXResponse


Examples of er.extensions.appserver.ERXResponse

    }

    @Override
    public WOResponse handleRequest(WORequest request) {
        if(!ERSelenium.testsEnabled()) {
            return new ERXResponse(ERXHttpStatusCodes.STATUS_FORBIDDEN);
        }
      NSArray pathElements = request.requestHandlerPathArray();
     
      StringBuilder builder = new StringBuilder();
      Iterator iter = pathElements.iterator();
      while (iter.hasNext()) {
        builder.append(iter.next());
        if (iter.hasNext())
          builder.append('/');
      }
     
    String filePath = builder.toString();
    log.debug("Processing file '" + filePath + "'");
   
    /*
     * Synchronization mistakes are possible here, but not fatal at all.
     * At the worst case the file will be read 2-or-more times instead of 1 (if process 1
     * checks that the file is not cached and process 2 does the same check before
     * process 1 has updated the cache).
     */
 
    CachedFile cachedFile;
    synchronized (_cache) {
      cachedFile = (CachedFile)_cache.objectForKey(filePath);
      }
   
    if (cachedFile == null) {
      cachedFile = new CachedFile();

      URL fileUrl = WOApplication.application().resourceManager().pathURLForResourceNamed(filePath, "ERSelenium", null);
      if (fileUrl == null) {
        throw new RuntimeException("Can't find specified resource ('" + filePath + "')");
      }
      cachedFile.mimeType = WOApplication.application().resourceManager().contentTypeForResourceNamed(filePath);
      if (cachedFile.mimeType == null) {
        throw new RuntimeException("Can't determine resource mime type ('" + filePath + "')");
      }
     
      try {
        cachedFile.data = new NSData(ERXFileUtilities.bytesFromInputStream(fileUrl.openStream()));
      } catch (Exception e) {
        throw new RuntimeException("Error reading file '" + fileUrl.getPath() + "'", e);
      }
     
      synchronized (_cache) {
        _cache.setObjectForKey(cachedFile, filePath);
        }
    }
     
    ERXResponse response = new ERXResponse();
    response.setHeader(cachedFile.mimeType, "content-type");
    response.setContent(cachedFile.data);
   
    NSNotificationCenter.defaultCenter().postNotification(WORequestHandler.DidHandleRequestNotification, response);
      return response;
    }
View Full Code Here

Examples of er.extensions.appserver.ERXResponse

        redirect.setUrl(url);
        return redirect;
    }
   
    private WOActionResults html(String url) {
        return new ERXResponse("<html><body><a href='" + url + "'>go</a><body></html>");
    }
View Full Code Here

Examples of er.extensions.appserver.ERXResponse

    }

    @Override
    public WOActionResults performActionNamed(String anActionName) {
        if(!ERSelenium.testsEnabled()) {
            return new ERXResponse(ERXHttpStatusCodes.STATUS_FORBIDDEN);
        }
        if("default".equals(anActionName)) {
            anActionName = null;
        } else if(new NSSelector(anActionName + "Action").implementedByObject(this)) {
            return super.performActionNamed(anActionName);
View Full Code Here

Examples of er.extensions.appserver.ERXResponse

  }

  @Override
  public WOActionResults performActionNamed(String anActionName) {
      if(!ERSelenium.testsEnabled()) {
          return new ERXResponse(ERXHttpStatusCodes.STATUS_FORBIDDEN);
      }
      if (anActionName.equals("default")) {
          return defaultAction();
      }
View Full Code Here

Examples of er.extensions.appserver.ERXResponse

        }
    }

   
    protected WOResponse dictionaryResponse(NSDictionary<?,?> dict) {
        ERXResponse response = new ERXResponse();
        response.appendContentString("<html><body>");
        for (Enumeration<?> e = dict.keyEnumerator(); e.hasMoreElements();) {
            Object key = e.nextElement();
            Object value = dict.objectForKey(key);
            response.appendContentString("<span id='" + key + "'>" + value + "</span>\n");
        }
        response.appendContentString("</body></html>");
        return response;
    }
View Full Code Here

Examples of er.extensions.appserver.ERXResponse

        response.appendContentString("</body></html>");
        return response;
    }
   
    protected WOResponse stringResponse(String s) {
        return new ERXResponse(s);   
    }
View Full Code Here

Examples of er.extensions.appserver.ERXResponse

        } catch (Exception e) {
          log.debug(e.getMessage());
        }
      }
     
      return new ERXResponse(report());
    }
View Full Code Here

Examples of er.extensions.appserver.ERXResponse

    }

    @Override
    public WOActionResults performActionNamed(String actionName) {
        if(!ERSelenium.testsEnabled()) {
            return new ERXResponse(ERXHttpStatusCodes.STATUS_FORBIDDEN);
        }
        if (actionName.equals("default"))
            return defaultAction();
        return processReport(actionName);
    }
View Full Code Here

Examples of er.extensions.appserver.ERXResponse

     * @param req the current ERXRequest for this RR cycle
     */
    public ERWSWOHTTPConnection(WORequest req)
    {
        woRequest = (ERXRequest)req;
        woResponse = new ERXResponse();
    }
View Full Code Here

Examples of er.extensions.appserver.ERXResponse

        if(isMetadataQuery(woRequest.queryString()))
        {
            SDDocument doc = wsdls.get(woRequest.queryString());
            if(doc == null)
            {
                ERXResponse resp = new ERXResponse();
                resp.setStatus(WOMessage.HTTP_STATUS_NOT_FOUND);
                return resp;
            }

            ERXResponse resp = new ERXResponse();

            resp.setStatus(HttpURLConnection.HTTP_OK);
            resp.setHeader("text/xml;charset=utf-8", "Content-Type");

            ByteArrayOutputStream baos = new ByteArrayOutputStream();

            WODynamicURL du = woRequest._uriDecomposed();
            String baseUri = String.format("%s/%s.woa/%s/%s",
                    du.prefix(),
                    du.applicationName(),
                    du.requestHandlerKey(),
                    du.requestHandlerPath());

            boolean isSecure;
           
            if(woRequest instanceof ERXRequest)
            {
                isSecure = ((ERXRequest)woRequest).isSecure();
            } else
            {
                isSecure = ERXRequest.isRequestSecure(woRequest);
            }
               
            String soapAddress = ERXResourceManager._completeURLForResource(
                    baseUri,
                    isSecure,
                    WOApplication.application().createContextForRequest(woRequest)
                    );

            try
            {
                doc.writeTo(new ERPortAddressResolver(soapAddress),
                            new ERDocumentAddressResolver(soapAddress),
                            baos);
                baos.flush();
            }
            catch(IOException e)
            {
            }

            resp.setContent(baos.toByteArray());

            return resp;
        }

        ERWSWOHTTPConnection con = new ERWSWOHTTPConnection(woRequest);
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.