Package com.webobjects.appserver

Examples of com.webobjects.appserver.WOResponse


          result = super.performActionNamed(anActionName);
        } else {
            log.error("Selenium tests support is disabled. You can turn them on using SeleniumTestsEnabled=true in Properties files");
            result = stringResponse(ERSelenium.SELENIUM_TESTS_DISABLED_MESSAGE);
        }
        WOResponse response = result.generateResponse();
        if(!session().isTerminating()) {
            result = response;
            session()._appendCookieToResponse(response);
        }
        log.debug("Out Session: " + session().sessionID() + response.cookies());
        return result;
    }
View Full Code Here


    }
    return data;
  }

  public WOResponse generateResponse() {
    WOResponse response;
    WOContext context = ERXWOContext.currentContext();
    if (_component instanceof WOActionResults) {
      response = ((WOActionResults)_component).generateResponse();
      responseAsPdf(response, context);
    } else {
View Full Code Here

    userInfo.setObjectForKey(message, InstantMessengerAdaptor.MESSAGE_KEY);
    userInfo.setObjectForKey(rawMessage, InstantMessengerAdaptor.RAW_MESSAGE_KEY);
    userInfo.setObjectForKey(conversation, InstantMessengerAdaptor.CONVERSATION_KEY);

    WORequest request = _application.createRequest("GET", uri.toString(), "HTTP/1.0", headers, null, userInfo);
    WOResponse response;
    try {
      response = _application.dispatchRequest(request);
      // String newSessionID = request.sessionID();
      // if (newSessionID != null) {
      // conversation.setSessionID(newSessionID);
      // }
      if (response != null) {
        String nextRequestUrl = response.headerForKey(InstantMessengerAdaptor.IM_ACTION_URL_KEY);
        conversation.setRequestUrl(nextRequestUrl);
        String responseMessage = response.contentString();
        if (responseMessage != null) {
          responseMessage = responseMessage.trim();
        }
        if (responseMessage != null && responseMessage.length() > 0) {
          if (log.isInfoEnabled()) {
View Full Code Here

        String serviceName = requestHandlerPath.objectAtIndex(0);

        ERJaxWebService<? extends Object> ws = registeredWebServices.get(serviceName);
        if(ws != null)
        {
            WOResponse resp = ws.handleRequest(aRequest);
            if(resp != null)
                return resp;

            return nullResponse();
        }
View Full Code Here

    if(context == null) {
      // AK: we provide the "handleException" with not much enough info to output a reasonable error message
      context = createContextForRequest(aRequest);
      didCreateContext = true;
    }
    WOResponse response = handleException(exception, context);
   
    // CH: If we have created a context, then the request handler won't know about it and can't put the components
    // from handleException(exception, context) to sleep nor check-in any session that may have been checked out
    // or created (e.g. from a component action URL.
    //
View Full Code Here

    // ASAP.
    handlePotentiallyFatalException(exception);

    // Not a fatal exception, business as usual.
    NSDictionary extraInfo = extraInformationForExceptionInContext(exception, context);
    WOResponse response = reportException(exception, context, extraInfo);
    if (response == null)
      response = super.handleException(exception, context);
    return response;
  }
View Full Code Here

   *            object
   * @return response
   */
  @Override
  public WOResponse dispatchRequest(WORequest request) {
    WOResponse response = null;
    ERXDelayedRequestHandler delayedRequestHandler = delayedRequestHandler();
    if(delayedRequestHandler == null) {
      response = dispatchRequestImmediately(request);
    } else {
      response = delayedRequestHandler.handleRequest(request);
View Full Code Here

  /**
   * Dispatches the request without checking for the delayedRequestHandler()
   * @param request
   */
  public WOResponse dispatchRequestImmediately(WORequest request) {
    WOResponse response;
    if (ERXApplication.requestHandlingLog.isDebugEnabled()) {
      ERXApplication.requestHandlingLog.debug(request);
    }

    try {
      ERXApplication._startRequest();
      ERXStats.initStatisticsIfNecessary();
      checkMemory();
      if (useComponentActionRedirection()) {
        ERXComponentActionRedirector redirector = ERXComponentActionRedirector.redirectorForRequest(request);
        if (redirector == null) {
          response = super.dispatchRequest(request);
          redirector = ERXComponentActionRedirector.currentRedirector();
          if (redirector != null) {
            response = redirector.redirectionResponse();
          }
        }
        else {
          response = redirector.originalResponse();
        }
      }
      else {
        response = super.dispatchRequest(request);
      }

    }
    finally {
      ERXStats.logStatisticsForOperation(statsLog, "key");
      ERXApplication._endRequest();
    }
    if (requestHandlingLog.isDebugEnabled()) {
      requestHandlingLog.debug("Returning, encoding: " + response.contentEncoding() + " response: " + response);
    }

    if (responseCompressionEnabled()) {
      String contentType = response.headerForKey("content-type");
      if (!"gzip".equals(response.headerForKey("content-encoding")) && (contentType != null) && (contentType.startsWith("text/") || responseCompressionTypes().containsObject(contentType))) {
        String acceptEncoding = request.headerForKey("accept-encoding");
        if ((acceptEncoding != null) && (acceptEncoding.toLowerCase().indexOf("gzip") != -1)) {
          long start = System.currentTimeMillis();
          long inputBytesLength;
          InputStream contentInputStream = response.contentInputStream();
          byte[] compressedData;
          if (contentInputStream != null) {
            inputBytesLength = response.contentInputStreamLength();
            NSData compressedNSData = ERXCompressionUtilities.gzipInputStreamAsNSData(contentInputStream, (int)inputBytesLength);
            //compressedData = compressedNSData._bytesNoCopy();
            compressedData = compressedNSData.bytes();
            response.setContentStream(null, 0, 0L);
          }
          else {
            NSData input = response.content();
            inputBytesLength = input.length();
            compressedData = (inputBytesLength > 0) ? ERXCompressionUtilities.gzipByteArray(input._bytesNoCopy()) : null;
          }
          if ( inputBytesLength > 0 ) {
            if (compressedData == null) {
              // something went wrong
            }
            else {
              response.setContent(new NSData(compressedData, new NSRange(0, compressedData.length), true));
              response.setHeader(String.valueOf(compressedData.length), "content-length");
              response.setHeader("gzip", "content-encoding");
              if (log.isDebugEnabled()) {
                log.debug("before: " + inputBytesLength + ", after " + compressedData.length + ", time: " + (System.currentTimeMillis() - start));
              }
            }
          }
View Full Code Here

    return context;
  }

  @Override
  public WOResponse createResponseInContext(WOContext context) {
    WOResponse response = new ERXResponse(context);
    return response;
  }
View Full Code Here

  /**
   * Overridden to make output XML compatible.
   */
    @Override
    public void appendToResponse(WOResponse woresponse, WOContext wocontext) {
        WOResponse newResponse = ERXPatcher.DynamicElementsPatches.cleanupXHTML ? new ERXResponse() : woresponse;
        super.appendToResponse(newResponse, wocontext);
       
        ERXPatcher.DynamicElementsPatches.processResponse(this, newResponse, wocontext, 0, nameInContext(wocontext, wocontext.component()));
        if (ERXPatcher.DynamicElementsPatches.cleanupXHTML) {
          woresponse.appendContentString(newResponse.contentString());
        }
    }
View Full Code Here

TOP

Related Classes of com.webobjects.appserver.WOResponse

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.