Package org.olat.core.util.vfs

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


  @Override
  public void deleteImage(Feed feed) {
    VFSContainer mediaContainer = getFeedMediaContainer(feed);
    String imageName = feed.getImageName();
    if (imageName != null) {
      VFSLeaf image = (VFSLeaf) mediaContainer.resolve(imageName);
      if (image != null) {
        image.delete();
        feed.setImageName(null);
      }
    }
  }
View Full Code Here


    // Don't copy metadata, since we don't edit them anyway.
    // Make a copy of the leaf
    // TODO:GW Copy the leaf
    VFSContainer parentContainer = file.getParentContainer();
    String newName = VFSManager.similarButNonExistingName(parentContainer, file.getName());
    VFSLeaf leafCopy = parentContainer.createChildLeaf(newName);
    VFSManager.copyContent(file, leafCopy);
    copy.setFile(leafCopy);
    copy.setHref(calculateHref(leafCopy));
    return copy;
  }
View Full Code Here

  /**
   * @see org.olat.repository.handlers.RepositoryHandler#getAsMediaResource(org.olat.resource.OLATResourceable)
   */
  public MediaResource getAsMediaResource(OLATResourceable res) {
    VFSContainer rootContainer = FileResourceManager.getInstance().getFileResourceRootImpl(res);
    VFSLeaf wikiZip = WikiToZipUtils.getWikiAsZip(rootContainer);
    return new VFSMediaResource(wikiZip);
  }
View Full Code Here

    VFSContainer rootContainer = frm.getFileResourceRootImpl(copy);
    //reset properties files to default values
    VFSContainer wikiCont = (VFSContainer)rootContainer.resolve(WikiManager.WIKI_RESOURCE_FOLDER_NAME);
    List leafs = wikiCont.getItems(new VFSItemSuffixFilter(new String[]{WikiManager.WIKI_PROPERTIES_SUFFIX}));
    for (Iterator iter = leafs.iterator(); iter.hasNext();) {
      VFSLeaf leaf = (VFSLeaf) iter.next();
      WikiPage page = Wiki.assignPropertiesToPage(leaf);
      //reset the copied pages to a the default values
      page.resetCopiedPage();
      WikiManager.getInstance().updateWikiPageProperties(copy, page);
    }
   
    //create folders
    VFSContainer newMediaCont = rootContainer.createChildContainer(WikiContainer.MEDIA_FOLDER_NAME);
    rootContainer.createChildContainer(WikiManager.VERSION_FOLDER_NAME);
    //copy media files to folders
    VFSContainer origRootContainer = frm.getFileResourceRootImpl(res);
    VFSContainer origMediaCont = (VFSContainer)origRootContainer.resolve(WikiContainer.MEDIA_FOLDER_NAME);
    List mediaFiles = origMediaCont.getItems();
    for (Iterator iter = mediaFiles.iterator(); iter.hasNext();) {
      VFSLeaf element = (VFSLeaf) iter.next();
      newMediaCont.copyFrom(element);
    }
    return copy;
  }
View Full Code Here

    return FileResourceManager.getInstance().getDetailsComponent(res, ureq.getLocale());
  }

  public String archive(Identity archiveOnBehalfOf, String archivFilePath, RepositoryEntry repoEntry) {
    VFSContainer rootContainer = FileResourceManager.getInstance().getFileResourceRootImpl(repoEntry.getOlatResource());
    VFSLeaf wikiZip = WikiToZipUtils.getWikiAsZip(rootContainer);
    String exportFileName = "del_wiki_" + repoEntry.getOlatResource().getResourceableId() + ".zip";
    String fullFilePath = archivFilePath + File.separator + exportFileName;
    File fExportZIP = new File(fullFilePath);
    FileOutputStream fos;
    try {
      fos = new FileOutputStream(fExportZIP);
      FileUtils.copy(wikiZip.getInputStream(),fos);
      fos.close();
    } catch (FileNotFoundException e) {
      Tracing.logWarn("Can not archive wiki repoEntry=" + repoEntry, this.getClass());
    } catch (IOException ioe) {
      Tracing.logWarn("Can not archive wiki repoEntry=" + repoEntry, this.getClass());
View Full Code Here

        // create new repository entry

        File f;
        String fName;
        if (cfc.isFileFromFolder()) {
          VFSLeaf vfsLeaf = cfc.getFileSelection();
          if (!(vfsLeaf instanceof LocalFileImpl)) {
            getWindowControl().setError(translator.translate("add.failed"));
            addCallback.failed(urequest);
            return;
          }
View Full Code Here

   * Zips the input vFSContainer into the container.
   * @param vFSContainer
   */
  private void zipContainer(VFSContainer vFSContainer) {
    String dateStamp = Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis()));   
    VFSLeaf zipVFSLeaf = container.createChildLeaf("forum_archive-"+dateStamp+".zip");   
    ZipUtil.zip(vFSContainer.getItems(), zipVFSLeaf);
  }
View Full Code Here

    List<VFSLeaf> leafs = new ArrayList<VFSLeaf>();
    for (int i = 0; i < allLeafs.size(); i++) {
      if (leafs.size() == itemsToDisplay) {
        break;
      }
      VFSLeaf leaf = allLeafs.get(i);
      leafs.add(leaf);
      // add link to item
      // Add link to jump to course node
      if (leaf instanceof LocalFileImpl) {
        LocalFileImpl localFile = (LocalFileImpl) leaf;
        String relPath = localFile.getBasefile().getAbsolutePath().substring(rootFolder.getBasefile().getAbsolutePath().length());
        Link nodeLink = LinkFactory.createLink("nodeLink_" + (i+1), peekviewVC, this);
        nodeLink.setCustomDisplayText(leaf.getName());
        int lastDot = localFile.getName().lastIndexOf(".");
        String cssClass = "";
        if (lastDot > 0 ) {
          cssClass = "b_filetype_" + localFile.getName().substring(lastDot+1);
        }
View Full Code Here

   */
  private void addItems(VFSContainer container, List<VFSLeaf> allLeafs) {
    for (VFSItem vfsItem : container.getItems()) {
      if (vfsItem instanceof VFSLeaf) {
        // add leaf to our list
        VFSLeaf leaf = (VFSLeaf) vfsItem;
        allLeafs.add(leaf);
      } else if (vfsItem instanceof VFSContainer) {
        // do it recursively for all children
        VFSContainer childContainer = (VFSContainer) vfsItem;
        addItems(childContainer, allLeafs);
View Full Code Here

  }

  public void testWriteToZip() {
    // Substract 1s = 1000ms from now to make sure the time is before execution
    long before = System.currentTimeMillis() - 1000;
    VFSLeaf zip = mgr.writeToZip(cp);
    assertNotNull("The zip file wasn't created properly", zip);
    assertTrue("The last modified date of the zip file wasn't updated", zip.getLastModified() > before);
  }
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.