Package org.olat.core.gui.media

Examples of org.olat.core.gui.media.StringMediaResource


        if(Tracing.isDebugEnabled(this.getClass())){
          Tracing.logDebug("scorm api request by user:"+ username +": " + apiCall + "('" + apiCallParamOne + "' , '" + apiCallParamTwo + "')", this.getClass());
        }

        String returnValue = "";
        StringMediaResource smr = new StringMediaResource();
        smr.setContentType("text/html");
        smr.setEncoding("utf-8");
       
        if (apiCall != null && apiCall.equals("initcall")) {
          //used for Mozilla / firefox only to get more time for fireing the onunload stuff triggered by overwriting the content.
          smr.setData("<html><body></body></html>");
          return smr;
        }
       

        if (apiCall != null) {
          if (apiCall.equals(LMS_INITIALIZE)) {
            returnValue = scormAdapter.LMSInitialize(apiCallParamOne);
          } else if (apiCall.equals(LMS_GETVALUE)) {
            returnValue = scormAdapter.LMSGetValue(apiCallParamOne);
          } else if (apiCall.equals(LMS_SETVALUE)) {
            returnValue = scormAdapter.LMSSetValue(apiCallParamOne, apiCallParamTwo);
          } else if (apiCall.equals(LMS_COMMIT)) {
            returnValue = scormAdapter.LMSCommit(apiCallParamOne);
          } else if (apiCall.equals(LMS_FINISH)) {
            returnValue = scormAdapter.LMSFinish(apiCallParamOne);
          } else if (apiCall.equals(LMS_GETLASTERROR)) {
            returnValue = scormAdapter.LMSGetLastError();
          } else if (apiCall.equals(LMS_GETDIAGNOSTIC)) {
            returnValue = scormAdapter.LMSGetDiagnostic(apiCallParamOne);
          } else if (apiCall.equals(LMS_GETERRORSTRING)) {
            returnValue = scormAdapter.LMSGetErrorString(apiCallParamOne);
          }
          smr.setData("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></head><body><p>"
              + returnValue + "</p></body></html>");
          return smr;
         
        }
        smr.setData("");
        return smr;
      }};
     
    String scormCallbackUri = mapreg.register(mapper);
    myContent.contextPut("scormCallbackUri", scormCallbackUri+"/");
View Full Code Here


      logWarn("GlossaryTerms delivery failed; glossaryFolder doesn't contain a valid Glossary: " + glossaryFolder, null);
      return new NotFoundMediaResource(relPath);
    }

    // Create a media resource
    StringMediaResource resource = new StringMediaResource() {
      @Override
      public void prepare(HttpServletResponse hres) {
      // don't use normal string media headers which prevent caching,
      // use standard browser caching based on last modified timestamp
      }
    };

    resource.setLastModified(gIM.getGlossaryLastModifiedTime(glossaryFolder));
    resource.setContentType("text/javascript");
    // Get data
    String glossaryArrayData = TextMarkerJsGenerator.loadGlossaryItemListAsJSArray(glossaryFolder);

    resource.setData(glossaryArrayData);
    // UTF-8 encoding used in this js file since explicitly set in the ajax
    // call (usually js files are 8859-1)
    resource.setEncoding("utf-8");
    return resource;
  }
View Full Code Here

    // cut away ".html"
    String glossaryMainTerm = parts[2].substring(0, parts[2].length() - 5).replace("+", " ");

    // Create a media resource
    StringMediaResource resource = new StringMediaResource() {
      @Override
      public void prepare(HttpServletResponse hres) {
      // don't use normal string media headers which prevent caching,
      // use standard browser caching based on last modified timestamp
      }
    };
    resource.setLastModified(gIM.getGlossaryLastModifiedTime(glossaryFolder));
    resource.setContentType("text/html");

    ArrayList<GlossaryItem> glossItems = gIM.getGlossaryItemListByVFSItem(glossaryFolder);
    String description = "<dd><dt>" + glossaryMainTerm + "</dt>";
    // FIXME: have a way not to loop over all items, but get by Term
    boolean foundADescription = false;
    for (Iterator<GlossaryItem> iterator = glossItems.iterator(); iterator.hasNext();) {
      GlossaryItem glossaryItem = iterator.next();
      if (glossaryItem.getGlossTerm().toLowerCase().equals(glossaryMainTerm.toLowerCase())) {
        description += "<dl>" + glossaryItem.getGlossDef() + "</dl>";
        foundADescription = true;
        break;
      }
    }
    description += "</dd>";
    if (!foundADescription) return new NotFoundMediaResource(relPath);
   
    resource.setData(description);
    resource.setEncoding("utf-8");

    if (isLogDebugEnabled()) logDebug("loaded definition for " + glossaryMainTerm, null);
    return resource;
  }
View Full Code Here

TOP

Related Classes of org.olat.core.gui.media.StringMediaResource

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.