Package org.olat.course.nodes.tu

Examples of org.olat.course.nodes.tu.TURequest


  }

 
  private void fetchFirstResource(Identity ident) {

    TURequest tureq = new TURequest(); //config, ureq);
    tureq.setContentType(null); // not used
    tureq.setMethod("GET");
    tureq.setParameterMap(Collections.EMPTY_MAP);
    tureq.setQueryString(query);
    if(startUri != null){
      if(startUri.startsWith("/")){
        tureq.setUri(startUri);
      }else{
        tureq.setUri("/"+startUri);
      }
    }

    //if (allowedToSendPersonalHeaders) {
    String userName = ident.getName();
    User u = ident.getUser();
    String lastName = u.getProperty(UserConstants.LASTNAME, loc);
    String firstName = u.getProperty(UserConstants.FIRSTNAME, loc);
    String email = u.getProperty(UserConstants.EMAIL, loc);
   
    tureq.setEmail(email);
    tureq.setFirstName(firstName);
    tureq.setLastName(lastName);
    tureq.setUserName(userName);
    //}

    HttpMethod meth = fetch(tureq, httpClientInstance);
    if (meth == null) {
      setFetchError();
    }else{

      Header responseHeader = meth.getResponseHeader("Content-Type");
      String mimeType;
      if (responseHeader == null) {
        setFetchError();
        mimeType = null;
      } else {
        mimeType = responseHeader.getValue();
      }
 
      if (mimeType != null && mimeType.startsWith("text/html")) {
        // we have html content, let doDispatch handle it for
        // inline rendering, update hreq for next content request
        String body;
        try {
          body = meth.getResponseBodyAsString();
        } catch (IOException e) {
          Tracing.logWarn("Problems when tunneling URL::" + tureq.getUri(), e, TunnelComponent.class);
          htmlContent = "Error: cannot display inline :"+tureq.getUri()+": Unknown transfer problem '";
          return;
        }
        SimpleHtmlParser parser = new SimpleHtmlParser(body);
        if (!parser.isValidHtml()) { // this is not valid HTML, deliver
          // asynchronuous
        }
        meth.releaseConnection();
        htmlHead = parser.getHtmlHead();
        jsOnLoad = parser.getJsOnLoad();
        htmlContent = parser.getHtmlContent();
      } else {
        htmlContent = "Error: cannot display inline :"+tureq.getUri()+": mime type was '" + mimeType +
          "' but expected 'text/html'. Response header was '" + responseHeader + "'.";
      }
    }
  }
View Full Code Here


    if (moduleURI == null) { // after a click on some other component e.g.
      if (!firstCall) return null;
      firstCall = false; // reset first call
    }

    TURequest tureq = new TURequest(config, ureq);

    //if (allowedToSendPersonalHeaders) {
    String userName = ureq.getIdentity().getName();
    User u = ureq.getIdentity().getUser();
    String lastName = u.getProperty(UserConstants.LASTNAME, loc);
    String firstName = u.getProperty(UserConstants.FIRSTNAME, loc);
    String email = u.getProperty(UserConstants.EMAIL, loc);
    tureq.setEmail(email);
    tureq.setFirstName(firstName);
    tureq.setLastName(lastName);
    tureq.setUserName(userName);
    //}

    HttpMethod meth = fetch(tureq, httpClientInstance);
    if (meth == null) {
      setFetchError();
      return null;
    }

    Header responseHeader = meth.getResponseHeader("Content-Type");
    if (responseHeader == null) {
      setFetchError();
      return null;
    }

    String mimeType = responseHeader.getValue();
    if (mimeType != null && mimeType.startsWith("text/html")) {
      // we have html content, let doDispatch handle it for
      // inline rendering, update hreq for next content request
      String body;
      try {
        body = meth.getResponseBodyAsString();
      } catch (IOException e) {
        Tracing.logWarn("Problems when tunneling URL::" + tureq.getUri(), e, TunnelComponent.class);
        return null;
      }
      SimpleHtmlParser parser = new SimpleHtmlParser(body);
      if (!parser.isValidHtml()) { // this is not valid HTML, deliver
        // asynchronuous
View Full Code Here

TOP

Related Classes of org.olat.course.nodes.tu.TURequest

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.