Examples of VFSContainer


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

   * @param oldRoot
   * @param fileName
   * @return
   */
  public static ContainerAndFile calculateSubRoot(VFSContainer oldRoot, String fileUri) {
    VFSContainer newC;
    String newFile;
    int sla = fileUri.lastIndexOf('/');
    if (sla != -1) {
      String root = fileUri.substring(0,sla);
      newFile = fileUri.substring(sla+1);
View Full Code Here

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

            // skip MacOSX specific metadata directory
            // create directories
            getAllSubdirs(targetDir, oEntr.getName(), true);
          } else {
            // create file
            VFSContainer createIn = targetDir;
            String name = oEntr.getName();
            // check if entry has directories which did not show up as
            // directories above
            int dirSepIndex = name.lastIndexOf('/');
            if (dirSepIndex == -1) {
              // try it windows style, backslash is also valid format
              dirSepIndex = name.lastIndexOf('\\');
            }
            if (dirSepIndex > 0) {
              // create subdirs
              createIn = getAllSubdirs(targetDir, name.substring(0, dirSepIndex), true);
              if (createIn == null) {
                if (log.isDebug()) log.debug("Error creating directory structure for zip entry: "
                    + oEntr.getName());
                return false;
              }
              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.VFSContainer

            oZip.closeEntry();
            oEntr = oZip.getNextEntry();
            continue;
          } else {
            // search file
            VFSContainer createIn = targetDir;
            String name = oEntr.getName();
            // check if entry has directories which did not show up as
            // directories above
            int dirSepIndex = name.lastIndexOf('/');
            if (dirSepIndex == -1) {
              // try it windows style, backslash is also valid format
              dirSepIndex = name.lastIndexOf('\\');
            }
            if (dirSepIndex > 0) {
              // get subdirs
              createIn = getAllSubdirs(targetDir, name.substring(0, dirSepIndex), false);
              if (createIn == null) {
                //sub directories don't exist, and aren't locked
                oZip.closeEntry();
                oEntr = oZip.getNextEntry();
                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.VFSContainer

      st = new StringTokenizer(subDirPath, "/", false);
    } else {
      // try it windows style, backslash is also valid format
      st = new StringTokenizer(subDirPath, "\\", false);
    }
    VFSContainer currentPath = base;
    while (st.hasMoreTokens()) {
      String nextSubpath = st.nextToken();
      VFSItem vfsSubpath = currentPath.resolve(nextSubpath);
      if (vfsSubpath == null && !create) {
        return null;
      }
      if (vfsSubpath == null || (vfsSubpath instanceof VFSLeaf)) {
        vfsSubpath = currentPath.createChildContainer(nextSubpath);
        if (vfsSubpath == null) return null;
      }
      currentPath = (VFSContainer)vfsSubpath;
    }
    return currentPath;
View Full Code Here

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

      renderList(renderer, target, fc, ubu, translator, iframePostEnabled);
  }

  private void renderList(Renderer r, StringOutput target, FolderComponent fc, URLBuilder ubu, Translator translator, boolean iframePostEnabled) {
   
    VFSContainer currentContainer = fc.getCurrentContainer();
    boolean canWrite = currentContainer.canWrite() == VFSConstants.YES;
    boolean canDelete = false;
    boolean canVersion = FolderConfig.versionsEnabled(fc.getCurrentContainer());
    for (Iterator<VFSItem> iter = fc.getCurrentContainerChildren().iterator(); iter.hasNext();) {
      VFSItem child = iter.next();
      if (child.canDelete() == VFSConstants.YES) {
View Full Code Here

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

    this.rootDir = rootDir;
    this.mainVC = createVelocityContainer("filechooser");

    // file uploads are relative to the currently edited file
    String[] dirs = this.fileName.split("/");
    VFSContainer fileUploadBase = rootDir;
    for (String subPath : dirs) {
      // try to resolve the given file path in the root container
      VFSItem subFolder = fileUploadBase.resolve(subPath);
      if (subFolder != null) {
        if (subFolder instanceof VFSContainer) {
          // a higher level found, use this one unless a better one is found
          fileUploadBase = (VFSContainer) subFolder;
        } else {
View Full Code Here

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

  @Override
  public List<Versions> getDeletedFiles(VFSContainer container) {
    List<Versions> deletedRevisions = new ArrayList<Versions>();

    VFSContainer versionContainer = getCanonicalVersionFolder(container, false);
    if (versionContainer != null) {
      Set<String> currentNames = new HashSet<String>();
      for (VFSItem item : container.getItems(new VFSLeafFilter())) {
        currentNames.add(item.getName() + ".xml");
      }

      List<VFSItem> versionItems = versionContainer.getItems(new VFSItemSuffixFilter(new String[] { "xml" }));
      for (VFSItem versionItem : versionItems) {
        if (versionItem instanceof VFSLeaf && !currentNames.contains(versionItem.getName())) {
          Versions versions = readVersions(null, (VFSLeaf) versionItem);
          List<VFSRevision> revisions = versions.getRevisions();
          if (!revisions.isEmpty()) {
View Full Code Here

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

    if (is == null) throw new NamingException(smgr.getString("resources.bindFailed", name));

    // Try to get Quota
    long quotaLeft = -1;
    boolean withQuotaCheck = false;
    VFSContainer parentContainer = file.getParentContainer();
    if (parentContainer != null) {
      quotaLeft = VFSManager.getQuotaLeftKB(parentContainer);
      if (quotaLeft != Quota.UNLIMITED) {
        quotaLeft = quotaLeft * 1024; // convert from kB
        withQuotaCheck = true;
View Full Code Here

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

  }

  private Versions readVersions(VFSLeaf leaf, VFSLeaf fVersions) {
    if (fVersions == null) { return new NotVersioned(); }

    VFSContainer fVersionContainer = fVersions.getParentContainer();
    VersionsFileImpl versions = (VersionsFileImpl) XStreamHelper.readObject(mystream, fVersions);
    versions.setVersionFile(fVersions);
    versions.setCurrentVersion((Versionable) leaf);
    if (versions.getRevisionNr() == null || versions.getRevisionNr().length() == 0) {
      versions.setRevisionNr(getNextRevisionNr(versions));
View Full Code Here

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

  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()) {
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.