Examples of VFSLeaf


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

              }
              name = name.substring(dirSepIndex + 1);
            }
           
            if(versioning) {
              VFSLeaf newEntry = (VFSLeaf)createIn.resolve(name);
              if(newEntry == null) {
                newEntry = createIn.createChildLeaf(name);
                OutputStream out = newEntry.getOutputStream(false);
                if (!FileUtils.copy(oZip, out)) return false;
                FileUtils.closeSafely(out);
              } else if (newEntry instanceof Versionable) {
                Versionable versionable = (Versionable)newEntry;
                if(versionable.getVersions().isVersioned()) {
                  versionable.getVersions().addVersion(identity, "", oZip);
                }
              }
            } else {
              VFSLeaf newEntry = createIn.createChildLeaf(name);
              if (newEntry != null) {
                OutputStream out = newEntry.getOutputStream(false);
                if (!FileUtils.copy(oZip, out)) return false;
                FileUtils.closeSafely(out);
              }
            }
          }
View Full Code Here

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

                continue;
              }
              name = name.substring(dirSepIndex + 1);
            }
           
            VFSLeaf newEntry = (VFSLeaf)createIn.resolve(name);
            if(MetaInfoHelper.isLocked(newEntry, identity, isAdmin)) {
              lockedFiles.add(name);
            }
          }
        }
View Full Code Here

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

        }
      };
    } else  if (col.equals(SORT_SIZE)) {                                            // sort after file size, folders always on top
      comparator = new Comparator<VFSItem>() {
        public int compare(VFSItem o1, VFSItem o2) {
          VFSLeaf leaf1 = null;
          if (o1 instanceof VFSLeaf) {
            leaf1 = (VFSLeaf)o1;
          }
          VFSLeaf leaf2 = null;
          if (o2 instanceof VFSLeaf) {
            leaf2 = (VFSLeaf)o2;
          }
          if        (leaf1 == null && leaf2 != null) return -1;                      // folders are always smaller
          else if    (leaf1 != null && leaf2 == null) return  1;                      // folders are always smaller   
          else if    (leaf1 == null && leaf2 == null)                                // if two folders, sort after name
            if (sortAsc) return collator.compare(o1.getName(), o2.getName());
            else         return collator.compare(o2.getName(), o1.getName());
          else                                                                      // if two leafes, sort after size
            if (sortAsc) return ((leaf1.getSize() < leaf2.getSize()) ? -1 1);
            else         return ((leaf1.getSize() < leaf2.getSize()) 1 : -1);
        }
      };
    } else if (col.equals(SORT_TYPE)) {                                              // sort after file type, folders always on top
      comparator = new Comparator<VFSItem>() {
        public int compare(VFSItem o1, VFSItem o2) {
View Full Code Here

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

  public void setComment(String comment) {
    this.comment = comment;
  }

  public long getSize() {
    VFSLeaf f = getFile();
    return f == null ? -1l : f.getSize();
  }
View Full Code Here

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

    VFSLeaf f = getFile();
    return f == null ? -1l : f.getSize();
  }

  public InputStream getInputStream() {
    VFSLeaf f = getFile();
    return f == null ? null : f.getInputStream();
  }
View Full Code Here

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

        versions = versionable.getVersions();
      }
    }
    boolean canVersion = versions != null && !versions.getRevisions().isEmpty();
   
    VFSLeaf leaf = null;
    if (child instanceof VFSLeaf) {
      leaf = (VFSLeaf)child;
    }
    boolean isContainer = (leaf == null); // if not a leaf, it must be a container...
   
    MetaInfo metaInfo = null;
    if(child instanceof OlatRelPathImpl) {
      metaInfo = MetaInfoFactory.createMetaInfoFor((OlatRelPathImpl)child);
    }
    boolean lockedForUser = MetaInfoHelper.isLocked(metaInfo, fc.getIdentityEnvironnement());
   
    String name = child.getName();
    String pathAndName = currentContainerPath;
    if (pathAndName.length() > 0 && !pathAndName.endsWith("/"))
      pathAndName = pathAndName + "/";
    pathAndName = pathAndName + name;
    String type = FolderHelper.extractFileType(child.getName(), translator.getLocale());
       
    // tr begin, set alternating bgcolor
    sb.append("<tr");
    bgFlag = !bgFlag;
    if (bgFlag) { sb.append(" class=\"b_table_odd\""); }
    sb.append("><td class=\"b_first_child\">");

    // add checkbox for actions if user can write or delete to this directory
    if (canWrite || canDelete) {
      sb.append("<input type=\"checkbox\" class=\"b_checkbox\" name=\"");
      sb.append(FileSelection.FORM_ID);
      sb.append("\" value=\"");
      sb.append(StringEscapeUtils.escapeHtml(name));
      sb.append("\" />");
    }   
   
    // browse link pre
    sb.append("<a href=\"");
    if (isContainer) { // for directories... normal module URIs
      ubu.buildURI(sb, null, null, pathAndName, iframePostEnabled ? AJAXFlags.MODE_TOBGIFRAME : AJAXFlags.MODE_NORMAL);
      sb.append("\"");
      if (iframePostEnabled) { // add ajax iframe target
        StringOutput so = new StringOutput();
        ubu.appendTarget(so);
        sb.append(so.toString());
      }
    } else { // for files, add PARAM_SERV command
      ubu.buildURI(sb, new String[] { PARAM_SERV }, new String[] { "x" }, pathAndName, AJAXFlags.MODE_NORMAL);
      sb.append("\" target=\"_blank\"");
    }
    // icon css
    sb.append(" class=\"b_with_small_icon_left ");
    if (isContainer) sb.append(CSSHelper.CSS_CLASS_FILETYPE_FOLDER);
    else sb.append(CSSHelper.createFiletypeIconCssClassFor(name));
    sb.append("\"");
    // file metadata
    if (metaInfo != null) {
      sb.append(" ext:qtip=\"<div class='b_ext_tooltip_wrapper b_briefcase_meta'>");
      if (StringHelper.containsNonWhitespace(metaInfo.getTitle())) {       
        sb.append("<h5>").append(Formatter.escapeDoubleQuotes(metaInfo.getTitle())).append("</h5>");   
      }
      if (StringHelper.containsNonWhitespace(metaInfo.getComment())) {
        sb.append(Formatter.escapeDoubleQuotes(metaInfo.getComment()));     
      }
      String author = metaInfo.getAuthor();
      if (StringHelper.containsNonWhitespace(author)) {
        sb.append("<p>").append(Formatter.escapeDoubleQuotes(translator.translate("mf.author")));
        sb.append(": ").append(Formatter.escapeDoubleQuotes(author)).append("</p>");     
      }
      sb.append("</div>\"");
    }
    sb.append(">");
    // name
    if (isAbstract) sb.append("<i>");
    sb.append(name);
    if (isAbstract) sb.append("</i>");
    sb.append("</a></td><td>");
   
    // filesize
    if (!isContainer) {
      // append filesize
      sb.append(StringHelper.formatMemory(leaf.getSize()));
    }
    sb.append("</td><td>");

    // type
    if (isContainer) {
View Full Code Here

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

    }
    return deletedRevisions;
  }

  private Versions readVersions(VFSLeaf leaf, boolean create) {
    VFSLeaf fVersions = getCanonicalVersionXmlFile(leaf, create);
    if (!create && fVersions == null) {
      VersionsFileImpl versions = new VersionsFileImpl();
      versions.setCurrentVersion((Versionable) leaf);
      versions.setVersioned(isVersioned(leaf));
      versions.setRevisionNr(getNextRevisionNr(versions));
View Full Code Here

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

    return versions;
  }

  @Override
  public boolean addVersion(Versionable currentVersion, Identity identity, String comment, InputStream newFile) {
    VFSLeaf currentFile = (VFSLeaf) currentVersion;
    if (addToRevisions(currentVersion, identity, comment)) {
      // copy the content of the new file to the old
      boolean closeInputStream = !(newFile instanceof net.sf.jazzlib.ZipInputStream || newFile instanceof java.util.zip.ZipInputStream);
      if (VFSManager.copyContent(newFile, currentFile, closeInputStream)) { return true; }
    } else {
View Full Code Here

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

    return false;
  }

  @Override
  public boolean move(Versionable currentVersion, VFSContainer container) {
    VFSLeaf currentFile = (VFSLeaf) currentVersion;
    VFSLeaf fVersions = getCanonicalVersionXmlFile(currentFile, true);
    Versions versions = readVersions(currentFile, fVersions);

    VFSContainer versionContainer = getCanonicalVersionFolder(container, true);

    boolean allOk = VFSConstants.YES.equals(versionContainer.copyFrom(fVersions));
    for (VFSRevision revision : versions.getRevisions()) {
      RevisionFileImpl revisionImpl = (RevisionFileImpl) revision;
      VFSLeaf revisionFile = revisionImpl.getFile();
      if (revisionFile != null) {
        allOk &= VFSConstants.YES.equals(versionContainer.copyFrom(revisionFile));
      }
    }

    allOk &= VFSConstants.YES.equals(fVersions.delete());
    for (VFSRevision revision : versions.getRevisions()) {
      VFSLeaf revisionFile = ((RevisionFileImpl) revision).getFile();
      if (revisionFile != null) {
        allOk &= VFSConstants.YES.equals(revisionFile.delete());
      }
    }
    return allOk;
  }
View Full Code Here

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

    return allOk;
  }

  @Override
  public boolean restore(Versionable currentVersion, VFSRevision version, String comment) {
    VFSLeaf currentFile = (VFSLeaf) currentVersion;
    if(!VFSManager.exists(currentFile)) {
      return false;
    }
   
    // add current version to versions file
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.