Package org.olat.core.gui.media

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


   * @param clazz The classpath that is used as a base
   * @param file The filepath relative to the classpath
   * @return a VFS leaf for the given file
   */
  public static VFSLeaf createLeafFromClasspath(Class clazz, String file) {
    ClasspathMediaResource cmr = new ClasspathMediaResource(clazz, file);
    StreamedImpl si = new StreamedImpl("vfs-from-classpath", null, cmr.getInputStream());   
    return si;
  }
View Full Code Here


   * @param baseClass
   * @param relPath
   * @return
   */
  public MediaResource createClassPathStaticFileMediaResourceFor(Class baseClass, String relPath) {
    return new ClasspathMediaResource(baseClass, STATIC_DIR_NAME + relPath);
  }
View Full Code Here

   * @param baseClass
   * @param relPath
   * @return
   */
  public MediaResource createClassPathStaticFileMediaResourceFor(Package pakkage, String relPath) {
    return new ClasspathMediaResource(pakkage, STATIC_DIR_NAME + relPath);
  }
View Full Code Here

   */
  private void initPageResourceMapper() {
    // Add page resources mapper
    Mapper pageResourceMapper = new Mapper() {
      public MediaResource handle(String relPath, HttpServletRequest request) {
        ClasspathMediaResource mr = null;
        // relPath: myimage.png
        int suffixPos = relPath.lastIndexOf(".");
        if (suffixPos > 0) {
          String mediaName = relPath.substring(0, suffixPos);
          String postfix = relPath.substring(suffixPos);
          // 1) try it with current language
          String fileName = mediaName + "_" + getLocale().toString() + postfix;
          mr = new ClasspathMediaResource(Package.getPackage(bundleName), ContextHelpModule.CHELP_STATIC_DIR + fileName);
          // 2) try it with default language
          if (!mr.resourceExists()) {
            fileName = mediaName + "_" + I18nModule.getDefaultLocale().toString() + postfix;
            mr = new ClasspathMediaResource(Package.getPackage(bundleName), ContextHelpModule.CHELP_STATIC_DIR + fileName);           
          }
          // 3) try it with fallback language
          if (!mr.resourceExists()) {
            fileName = mediaName + "_" + I18nModule.getFallbackLocale().toString() + postfix;
            mr = new ClasspathMediaResource(Package.getPackage(bundleName), ContextHelpModule.CHELP_STATIC_DIR + fileName);           
          }
        }
        // If not even a fallback image is found, serve a not-found resource
        if (!mr.resourceExists()) {
          return new NotFoundMediaResource(relPath);
        }
        return mr;
      }
    };
View Full Code Here

   * @param loc
   */
  public void setLanguage(Locale loc) {
    // tiny does not support country or vairant codes, only language code
    String langKey = loc.getLanguage();
    ClasspathMediaResource resource = new ClasspathMediaResource(this.getClass(), "_static/js/tinymce/langs/" + langKey + ".js");
    if (resource.getInputStream() == null) {
      // fallback to EN
      langKey = "en";
    }
    setQuotedConfigValue(LANGUAGE, langKey);
  }
View Full Code Here

    // codeblock)
    final Mapper mapper = new Mapper() {
      public MediaResource handle(String relPath, HttpServletRequest request) {
        // nothing under "raw" should be sensitive information since, by entering
        // the appropriate url, any resources in this folder and in subfolders is served.
        return new ClasspathMediaResource(baseClass, "raw" + relPath);
      }
    };

    // --- register a global mapper for static resource delegated to this
    // extension
View Full Code Here

TOP

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

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.