Package org.olat.core.util.vfs

Examples of org.olat.core.util.vfs.VFSLeaf


    // if version matches recent version the current pags is requested
    if (version == page.getVersion() && !page.getContent().equals("")) return page;
    if (version == 0) return new WikiPage("dummy");
    if (page.getPageName().equals("dummy")) return page;
    WikiPage pageVersion = null;
    VFSLeaf versionLeaf = (VFSLeaf) versionsContainer.resolve(page.getPageId() + "." + WikiManager.WIKI_PROPERTIES_SUFFIX + "-" + version);
    pageVersion = assignPropertiesToPage(versionLeaf);
    VFSLeaf contentLeaf = (VFSLeaf) versionsContainer.resolve(page.getPageId() + "." + WikiManager.WIKI_FILE_SUFFIX + "-" + version);
    if (contentLeaf != null) {
      pageVersion.setContent(FileUtils.load(contentLeaf.getInputStream(), "utf-8"));
    } else {
      pageVersion.setContent("");
    }
    return pageVersion;
View Full Code Here


   */
  public boolean mediaFileExists(String imageName) {
    List<VFSItem> mediaFiles = getMediaFileList();
    if (mediaFiles.size() == 0) return false;
    for (Iterator<VFSItem> iter = mediaFiles.iterator(); iter.hasNext();) {
      VFSLeaf leaf = (VFSLeaf) iter.next();
      if (leaf.getName().equals(Utilities.encodeForURL(imageName))) return true;
    }
    return false;
  }
View Full Code Here

    StringBuilder sb = new StringBuilder();
    sb.append("<html><head>");
    sb.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">");
    sb.append("</head><body><ul>");
    for (Iterator iter = vfsLeaves.iterator(); iter.hasNext();) {
      VFSLeaf element = (VFSLeaf) iter.next();
      // destination.copyFrom(element);
      if (element.getName().endsWith(WikiManager.WIKI_PROPERTIES_SUFFIX)) {
        hasProperties = true;
        Properties p = new Properties();
        try {
          p.load(element.getInputStream());
        } catch (IOException e) {
          throw new AssertException("Wiki propterties couldn't be read! ", e);
        }
        sb.append("<li>");
        sb.append(p.getProperty(WikiManager.PAGENAME));
        sb.append(" ----> ");
        sb.append(element.getName().substring(0, element.getName().indexOf(".")));
        sb.append("</li>");
      }
    }
    sb.append("</ul></body></html>");
    if(!hasProperties) return null;
View Full Code Here

   * @param rootContainer
   * @return
   */
  public static VFSLeaf getWikiAsZip(VFSContainer rootContainer){
    List folders = rootContainer.getItems();
    VFSLeaf indexLeaf =(VFSLeaf)rootContainer.resolve("index.html");
    if(indexLeaf != null) indexLeaf.delete();
    List filesTozip = new ArrayList();
    for (Iterator iter = folders.iterator(); iter.hasNext();) {
      VFSItem item = (VFSItem)iter.next();
      if (item instanceof VFSContainer) {
        VFSContainer folder = (VFSContainer) item;
        List items = folder.getItems();
        String overviewPage = WikiToZipUtils.createIndexPageForExport(items);
        if(overviewPage != null){
          VFSLeaf overview = rootContainer.createChildLeaf("index.html");
          items.add(overview);
          FileUtils.save(overview.getOutputStream(false), overviewPage, "utf-8");
        }
        filesTozip.addAll(items);
      }
    }
    VFSLeaf zipFile = (VFSLeaf)rootContainer.resolve("wiki.zip");
    if(rootContainer.resolve("wiki.zip") != null) zipFile.delete();
    ZipUtil.zip(filesTozip, rootContainer.createChildLeaf("wiki.zip"));
    return (VFSLeaf)rootContainer.resolve("wiki.zip");
  }
View Full Code Here

    int pos = Integer.parseInt(cmd.substring(cmd.indexOf("_") + 1, cmd.lastIndexOf("_")));
    // velocity counter starts at 1
    List<VFSItem> attachments = new ArrayList<VFSItem>();
    attachments.addAll((Collection<VFSItem>) messageMap.get("attachments"));
    VFSItem vI = attachments.get(pos - 1);
    VFSLeaf vl = (VFSLeaf) vI;
    ureq.getDispatchResult().setResultingMediaResource(new VFSMediaResource(vl));
  }
View Full Code Here

    String dateStamp = Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis()));
    LocalFolderImpl exportDir =  new OlatRootFolderImpl(FolderConfig.getUserHomes() +"/"+ ident.getName() +"/private/archive/wiki-export-"+dateStamp+".zip", null);
   
    //create the ims manifest
    StringBuilder sb = createIMSManifest(wiki, ident);
    VFSLeaf manifest = tempFolder.createChildLeaf("imsmanifest.xml");
    copyMediaFiles(WikiManager.getInstance().getMediaFolder(ores), tempFolder);
    FileUtils.save(manifest.getOutputStream(false), sb.toString(), "utf-8");
   
    //create the javascript mapping file
    StringBuilder jsContent = createJsMappingContent(wiki);
    VFSLeaf jsFile = tempFolder.createChildLeaf("mapping.js");
    FileUtils.save(jsFile.getOutputStream(false), jsContent.toString(), "utf-8");
   
    renderWikiToHtmlFiles(ores, tempFolder);
    CPOfflineReadableManager.getInstance().makeCPOfflineReadable(tempFolder.getBasefile(), exportDir.getBasefile(), null);
    tempFolder.delete();
  }
View Full Code Here

  }

  private void copyMediaFiles(OlatRootFolderImpl mediaFolder, VFSContainer tempFolder) {
    List images = mediaFolder.getItems();
    for (Iterator iter = images.iterator(); iter.hasNext();) {
      VFSLeaf image = (VFSLeaf) iter.next();
      tempFolder.copyFrom(image);
    }
  }
View Full Code Here

      if(page.getPageName().equals(WikiPage.WIKI_A2Z_PAGE)) sb.append(trans.translate("navigation.a-z"));
      else if(page.getPageName().equals(WikiPage.WIKI_MENU_PAGE)) sb.append(trans.translate("navigation.menu"));
      else sb.append(page.getPageName());
      sb.append("</h3>");
      sb.append("<hr><div id=\"olat-wiki\">");
      VFSLeaf file = tempFolder.createChildLeaf(page.getPageId()+".html");
      try {
        ParserDocument doc = parser.parseHTML(page.getContent());
        sb.append(doc.getContent());
      } catch (Exception e) {
        throw new OLATRuntimeException("error while parsing from wiki to cp. ores:"+ores.getResourceableId(), e);
      }
      sb.append("</div></body></html>");
      FileUtils.save(file.getOutputStream(false), sb.toString(), "utf-8");
    }
   
  }
View Full Code Here

    OLATResourceManager rm = OLATResourceManager.getInstance();
    OLATResource ores = rm.createOLATResourceInstance(feedResource);
    rm.saveOLATResource(ores);
    Feed feed = new Feed(feedResource);
    VFSContainer podcastContainer = getFeedContainer(feedResource);
    VFSLeaf leaf = podcastContainer.createChildLeaf(FEED_FILE_NAME);
    podcastContainer.createChildContainer(MEDIA_DIR);
    podcastContainer.createChildContainer(ITEMS_DIR);
    XStreamHelper.writeObject(xstream, leaf, feed);
    return feedResource;
  }
View Full Code Here

        // Update the image
        String imageFilename = RepositoryEntryImageController.getImageFilename(entry);
        String repoImagePath = FolderConfig.getCanonicalRoot() + FolderConfig.getRepositoryHome() + "/" + imageFilename;
        File repoEntryImage = new File(repoImagePath);
        if (repoEntryImage.exists()) {
          VFSLeaf repoImage = new LocalFileImpl(repoEntryImage);
          getFeedMediaContainer(feed).copyFrom(repoImage);
          VFSLeaf newImage = (VFSLeaf) getFeedMediaContainer(feed).resolve(imageFilename);
          if (newImage != null) {
            feed.setImageName(imageFilename);
          }
        } else {
          // There's no repo entry image -> delete the feed image as well.
View Full Code Here

TOP

Related Classes of org.olat.core.util.vfs.VFSLeaf

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.