Package org.olat.core.util.vfs

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


  private List<VFSItem> getSanityCheckedSourceItems(VFSContainer target, UserRequest ureq) {
    // collect all source files first
   
    List<VFSItem> sources = new ArrayList<VFSItem>();
    for (String sourceRelPath:fileSelection.getFiles()) {
      VFSItem vfsSource = folderComponent.getCurrentContainer().resolve(sourceRelPath);
      if (vfsSource == null) {
        abortFailed(ureq, "FileDoesNotExist");
        return null;
      }
      if (vfsSource instanceof VFSContainer) {
        // if a folder... check if they are overlapping
        if (VFSManager.isContainerDescendantOrSelf(target, (VFSContainer)vfsSource)) {
          abortFailed(ureq, "OverlappingTarget");
          return null;
        }
      }
      if (MetaInfoHelper.isLocked(vfsSource, ureq)) {
        abortFailed(ureq, "lock.title");
        return null;
      }

      // check for existence... this will also prevent to copy item over itself
      VFSItem item = target.resolve(vfsSource.getName());
      if (item != null) {
        abortFailed(ureq, "TargetNameAlreadyUsed");
        return null;
      }
     
View Full Code Here


   * @param isPopUp
   */
  protected MediaResource deliverFile(String path, boolean isPopUp) {
    MediaResource mr;
    VFSLeaf vfsLeaf = null;
    VFSItem vfsItem = null;
    //if directory gets renamed root becomes null
    if (rootDir == null) {
      return new NotFoundMediaResource("directory not found"+path);
    } else {
      vfsItem = rootDir.resolve(path);
View Full Code Here

           
    @Override
    protected void formOK(UserRequest ureq) {     
      //create the file
      VFSContainer currentContainer = folderComponent.getCurrentContainer();
      VFSItem item = currentContainer.createChildLeaf(getItemName());
      if (item == null) {       
        this.fireEvent(ureq, Event.FAILED_EVENT);
        return;
      }
      if (item instanceof OlatRelPathImpl) {
View Full Code Here

          //add html extension if missing
          fileName = fileName + ".html";
        }
        //ok, file name is sanitized, let's see if a file with this name already exists
        VFSContainer currentContainer = folderComponent.getCurrentContainer();
        VFSItem item = currentContainer.resolve(fileName);
        if (item != null) {
          textElement.setErrorKey("cfile.already.exists", new String[] {fileName});
          isInputValid = false;
        } else {
          isInputValid = true;         
View Full Code Here

      }

      // make sure moduleURI does not contain ".." or such (hack attempt)
      // -> ok, userrequest class asserts this.

      VFSItem sourceItem = rootContainer.resolve(moduleURI);
      // return 404 if the requested file does not exist
      if (sourceItem == null || (sourceItem instanceof VFSContainer)) {
        return new NotFoundMediaResource(moduleURI);
      }
      // we know the file exists.
View Full Code Here

  private Mapper createMapper(final VFSContainer mapperRootContainer) {
   
    Mapper map = new Mapper() {
      public MediaResource handle(String relPath, HttpServletRequest request) {
        Tracing.logDebug("CPComponent Mapper relPath=" + relPath,HtmlStaticPageComponent.class);
        VFSItem currentItem = mapperRootContainer.resolve(relPath);
        if (currentItem == null || (currentItem instanceof VFSContainer)) {
          return new NotFoundMediaResource(relPath);
        }
        VFSMediaResource vmr = new VFSMediaResource((VFSLeaf)currentItem);
        String encoding = SimpleHtmlParser.extractHTMLCharset(((VFSLeaf)currentItem));
View Full Code Here

      throw new AssertException("can only accept files which are inline renderable(.html, .htm, .txt), but given filename is:" + currentURI);
    }
    this.currentURI = currentURI;
    setDirty(true);
   
    VFSItem sourceItem = null;
    if (rootContainer != null)
      sourceItem = rootContainer.resolve(currentURI);
    if (sourceItem == null || (sourceItem instanceof VFSContainer)) {
      jsOnLoad = null;
      htmlHead = null;
View Full Code Here

   * Wrapp all LocalImpls to OlatRootImpls
   *
   * @see org.olat.core.util.vfs.VFSContainer#createChildContainer(java.lang.String)
   */
  public VFSContainer createChildContainer(String name) {
    VFSItem result = super.createChildContainer(name);
    if (result == null) return null;
    return new OlatRootFolderImpl(folderRelPath + "/" + name, this);
  }
View Full Code Here

   * Wrapp all LocalImpls to OlatRootImpls
   *
   * @see org.olat.core.util.vfs.VFSContainer#createChildLeaf(java.lang.String)
   */
  public VFSLeaf createChildLeaf(String name) {
    VFSItem result = super.createChildLeaf(name);
    if (result == null) return null;
    return new OlatRootFileImpl(folderRelPath + "/" + name, this);
  }
View Full Code Here

      return null;
    }   
   
    List<String> lockedFiles = new ArrayList<String>();
    for (String sItem:selection.getFiles()) {
      VFSItem vfsItem = currentContainer.resolve(sItem);
      if (vfsItem instanceof VFSLeaf) {
        boolean isAdmin = ureq.getUserSession().getRoles().isOLATAdmin();
        lockedFiles.addAll(checkLockedFiles((VFSLeaf)vfsItem, currentContainer, ureq.getIdentity(), isAdmin));
      }
    }
   
    if(!lockedFiles.isEmpty()) {
      String msg = MetaInfoHelper.renderLockedMessageAsHtml(trans, null, lockedFiles);
      List<String> buttonLabels = Collections.singletonList(trans.translate("ok"));
      lockedFiledCtr = activateGenericDialog(ureq, trans.translate("lock.title"), msg, buttonLabels, lockedFiledCtr);
      return null;
    }
   
    boolean fileNotExist = false;
    for (String sItem:selection.getFiles()) {
      VFSItem vfsItem = currentContainer.resolve(sItem);
      if (vfsItem != null && (vfsItem instanceof VFSLeaf)) {
        if (!doUnzip((VFSLeaf)vfsItem, currentContainer, ureq, wContr)) {
          status = FolderCommandStatus.STATUS_FAILED;
          break;
        }
View Full Code Here

TOP

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

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.