Package com.webobjects.appserver

Examples of com.webobjects.appserver.WOContext


  public static WOSession existingSession(WORequest request) {
    WOApplication app = WOApplication.application();
    String sessionID = request.stringFormValueForKey(app.sessionIdKey());
    WOSession session = null;
    if(sessionID != null) {
      WOContext context = app.createContextForRequest(request);
      session = app.restoreSessionWithID(sessionID, context);
    }
    return session;
  }
View Full Code Here


     * @param results */
    public static void createRedirector(WOActionResults results) {
        ERXThreadStorage.removeValueForKey("redirector");
        if(results instanceof WOComponent) {
            WOComponent component = (WOComponent)results;
            WOContext context = component.context();
            if(context.request().requestHandlerKey().equals("wo")) {
                if(component instanceof Restorable) {
                    ERXComponentActionRedirector r = new ERXComponentActionRedirector((Restorable)component);
                    ERXComponentActionRedirector.storeRedirector(r);
                } else {
                    log.debug("Not restorable: " + context.request().uri() + ", " + component);
                }
            }
        }
    }
View Full Code Here

    /** contructs the redirector from the Restorable.
     * @param r - Restorable component used to construct a redirector */
    public ERXComponentActionRedirector(Restorable r) {
        WOComponent component = (WOComponent)r;
        WOContext context = component.context();
        sessionID = component.session().sessionID();
        url = r.urlForCurrentState();
        if(context.session().storesIDsInURLs()) {
          String argsChar = url.indexOf("?") >= 0? "&" : "?";
          String sessionIdKey = WOApplication.application().sessionIdKey();
          if(url.indexOf(sessionIdKey + "=") < 0) {
              url = url + argsChar + sessionIdKey + "=" +sessionID;
              argsChar = "&";
          }
          if(url.indexOf("wocid=") < 0) {
              url = url + argsChar + "wocid=" + context.contextID();
          }
        }
        redirectionResponse = WOApplication.application().createResponseInContext(context);
        redirectionResponse.setHeader(url, "location");
        redirectionResponse.setStatus(302);
View Full Code Here

  public SeleniumStartTesting(WORequest request) {
    super(request);
  }
 
  public String buildUrl(String suite, boolean auto) {
    WOContext context = context();
        // context._generateCompleteURLs();
    String baseUrl = "http://" + WOApplication.application().hostAddress().getHostAddress();
   
    StringBuilder queryStr = new StringBuilder();
//    queryStr.append("baseUrl=" + baseUrl);
    queryStr.append("test=" + context.directActionURLForActionNamed("SeleniumTestSuite" + (suite != null ? "/" + suite :  ""), null));
    queryStr.append("&resultsUrl=" + context.directActionURLForActionNamed( "SeleniumTestResults", null));
    //TODO: add filename check here
    String resultsFile = (String)context().request().formValueForKey(RESULTS_FILE_KEY);
    if (resultsFile != null)
      queryStr.append("/" + resultsFile);
   
    if (auto)
      queryStr.append("&auto=true");
    String url = context.urlWithRequestHandlerKey("_sl_", "selenium-core/TestRunner.html", queryStr.toString());
        // doesn't work, pity
        // url = url.replaceFirst(".*?selenium-core/TestRunner.html", "chrome://selenium-ide/content/selenium/TestRunner.html");
        return url;
  }
View Full Code Here

        }
        return currentError.thrownException();
    }
    // external factory methods
    public static WOComponent reportFromBatchTestInterface(ERXBatchTestInterface bti) {
        ERXWOTestResult report = (ERXWOTestResult)WOApplication.application().pageWithName("ERXWOTestResult", new WOContext(new WORequest(null,null,null,null,null,null)));
        report.takeValueForKey(bti.testResult(), "testResult");
        report.takeValueForKey(bti.errorMessage(), "errorMessage");
        report.takeValueForKey(Long.valueOf(bti.runTime()), "runTime");
        report.takeValueForKey(bti.test(), "test");
        report.takeValueForKey(bti.showExceptions() ? Boolean.TRUE : Boolean.FALSE, "showExceptions");
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 {
      response = WOApplication.application().createResponseInContext(context);

      WOElement currentElement = context._pageElement();
      context._setPageElement(_component);
      appendToResponse(response, context);
      context._setPageElement(currentElement);
    }
    return response;
  }
View Full Code Here

  }

    @PropertySet.Property({ "er.extensions.appserver.ERXWOContext" })
    public synchronized ERXWOContext ERXWOContext()
    {
        WOContext c = WOContext();
       
        if(c instanceof ERXWOContext)
        {
            return (ERXWOContext)c;
        }
View Full Code Here

   * @param pageName -
   *            The name of the WOComponent that must be instantiated.
   * @return created WOComponent with the given name
   */
  public static WOComponent instantiatePage(String pageName) {
    WOContext context = ERXWOContext.newContext();
    return application().pageWithName(pageName, context);
  }
View Full Code Here

  // NOTE: if you use WO 5.1, comment out this method, otherwise it won't
  // compile.
  // CHECKME this was created for WO 5.2, do we still need this for 5.4.3?
  @Override
  public WOResponse handleActionRequestError(WORequest aRequest, Exception exception, String reason, WORequestHandler aHandler, String actionClassName, String actionName, Class actionClass, WOAction actionInstance) {
    WOContext context = actionInstance != null ? actionInstance.context() : null;
    boolean didCreateContext = false;
    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.
    //
    // I'm not sure if the reasoning below was valid, or of the real cause of this deadlocking was creating the context
    // above and then creating / checking out a session during handleException(exception, context).  In any case, a zombie
    // session was getting created with WO 5.4.3 and this does NOT happen with a pure WO application making the code above
    // a prime suspect.  I am leaving the code below in so that if it does something for prior versions, that will still work.
    if (didCreateContext)
    {
      context._putAwakeComponentsToSleep();
      saveSessionForContext(context);
    }
   
    // AK: bugfix for #4186886 (Session store deadlock with DAs). The bug
    // occurs in 5.2.3, I'm not sure about other
    // versions.
    // It may create other problems, but this one is very severe to begin
    // with
    // The crux of the matter is that for certain exceptions, the DA request
    // handler does not check sessions back in
    // which leads to a deadlock in the session store when the session is
    // accessed again.
    else if (context.hasSession() && ("InstantiationError".equals(reason) || "InvocationError".equals(reason))) {
      context._putAwakeComponentsToSleep();
      saveSessionForContext(context);
    }
    return response;
  }
View Full Code Here

   *            the request
   * @return the newly created context
   */
  @Override
  public WOContext createContextForRequest(WORequest request) {
    WOContext context = super.createContextForRequest(request);
    // We only want to push in the context the first time it is
    // created, ie we don't want to lose the current context
    // when we create a context for an error page.
    if (ERXWOContext.currentContext() == null) {
      ERXWOContext.setCurrentContext(context);
View Full Code Here

TOP

Related Classes of com.webobjects.appserver.WOContext

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.