Examples of VFSContainer


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

   * @param fc
   * @param selection
   * @return
   */
  public static final int sanityCheck3(WindowControl wControl, FolderComponent fc, FileSelection selection) {
    VFSContainer container = fc.getCurrentContainer();
    for(String filename : selection.getFiles()) {
      if(container.resolve(filename) == null) {
        wControl.setError(fc.getTranslator().translate("FileDoesNotExist"));
        return FolderCommandStatus.STATUS_FAILED;
      }
    }
    return FolderCommandStatus.STATUS_SUCCESS; 
View Full Code Here

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

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

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

          textElement.setErrorKey("cf.name.notvalid", new String[0]);
          isInputValid = false;
          return isInputValid;
        }
        //ok, folder name is sanitized, let's see if a folder with this name already exists
        VFSContainer currentContainer = folderComponent.getCurrentContainer();       
        VFSItem item = currentContainer.resolve(name);
        if (item != null) {
          textElement.setErrorKey("cf.exists", new String[] {name});
          isInputValid = false;
        } else {
          isInputValid = true;
View Full Code Here

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

        if (selectedPath == null) {
          abortFailed(ureq, "failed");
          return;
        }
        VFSStatus vfsStatus = VFSConstants.SUCCESS;
        VFSContainer rootContainer = folderComponent.getRootContainer();
        VFSItem vfsItem = rootContainer.resolve(selectedPath);
        if (vfsItem == null || (vfsItem.canWrite() != VFSConstants.YES)) {
          abortFailed(ureq, "failed");
          return;
        }
        // copy the files
        VFSContainer target = (VFSContainer)vfsItem;
        List<VFSItem> sources = getSanityCheckedSourceItems(target, ureq);
        if (sources == null) return;
       
        boolean targetIsRelPath = (target instanceof OlatRelPathImpl);
        for (VFSItem vfsSource:sources) {
          if (targetIsRelPath && (vfsSource instanceof OlatRelPathImpl)) {
            // copy the metainfo first
            MetaInfo meta = MetaInfoFactory.createMetaInfoFor((OlatRelPathImpl)vfsSource);
            meta.moveCopyToDir((OlatRelPathImpl)target, move);
          }
         
          VFSItem targetFile = target.resolve(vfsSource.getName());
          if(vfsSource instanceof VFSLeaf && targetFile != null && targetFile instanceof Versionable
              && ((Versionable)targetFile).getVersions().isVersioned()) {
            //add a new version to the file
            ((Versionable)targetFile).getVersions().addVersion(null, "", ((VFSLeaf)vfsSource).getInputStream());
          } else {
            vfsStatus = target.copyFrom(vfsSource);
          }
          if (vfsStatus != VFSConstants.SUCCESS) {
            String errorKey = "failed";
            if (vfsStatus == VFSConstants.ERROR_QUOTA_EXCEEDED)
              errorKey = "QuotaExceeded";
View Full Code Here

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

    }   
           
    @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

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

        } else if (!fileName.endsWith(".html") && !fileName.endsWith(".htm") && !fileName.endsWith(".txt") && !fileName.endsWith(".css")) {
          //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

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

 
 
  public Controller execute(FolderComponent folderComponent, UserRequest ureq, WindowControl wContr, Translator trans) {
    this.translator = trans;
    FileSelection selection = new FileSelection(ureq, folderComponent.getCurrentContainerPath());
    VFSContainer currentContainer = folderComponent.getCurrentContainer();
    if (!(currentContainer.canWrite() == VFSConstants.YES))
      throw new AssertException("Cannot unzip to folder. Writing denied.");
     
    //check if command is executed on a file containing invalid filenames or paths - checks if the resulting folder has a valid name
    if(selection.getInvalidFileNames().size()>0) {       
      status = FolderCommandStatus.STATUS_INVALID_NAME;
      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

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

    // we make a new folder with the same name as the zip file
    String sZipContainer = name.substring(0, name.length() - 4);
   
    boolean versioning = FolderConfig.versionsEnabled(currentContainer);
   
    VFSContainer zipContainer = currentContainer.createChildContainer(sZipContainer);
    if (zipContainer == null) {
      if(versioning) {
        zipContainer =(VFSContainer)currentContainer.resolve(sZipContainer);
      } else {
        // folder already exists... issue warning
        wControl.setError(translator.translate("unzip.alreadyexists", new String[] {sZipContainer}));
        return false;
      }
    }
    if (!ZipUtil.unzip(vfsItem, zipContainer, ureq.getIdentity(), versioning)) {
      // operation failed - rollback
      zipContainer.delete();
      return false;
    } else {
      // check quota
      long quotaLeftKB = VFSManager.getQuotaLeftKB(currentContainer);
      if (quotaLeftKB != Quota.UNLIMITED && quotaLeftKB < 0) {
        // quota exceeded - rollback
        zipContainer.delete();
        wControl.setError(translator.translate("QuotaExceeded"));
        return false;
      }
    }
    return true;
View Full Code Here

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

        String fileName = metaInfoCtr.getFilename();
       
        if (metaInfoCtr.isFileRenamed()) {
          // IMPORTANT: First rename the meta data because underlying file
          // has to exist in order to work properly on it's meta data.
          VFSContainer container = currentItem.getParentContainer();
          if(container.resolve(fileName) != null) {
            getWindowControl().setError(translator.translate("TargetNameAlreadyUsed"));
            status = FolderCommandStatus.STATUS_FAILED;
          } else {
            if (meta != null) {
              meta.rename(fileName);
View Full Code Here

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

  public Controller execute(FolderComponent fc, UserRequest ureq, WindowControl wContr, Translator trans) {
    this.translator = trans;
    this.folderComponent = fc;
    this.fileSelection = new FileSelection(ureq, fc.getCurrentContainerPath());

    VFSContainer currentContainer = folderComponent.getCurrentContainer();
    List<String> lockedFiles = MetaInfoHelper.hasLockedFiles(currentContainer, fileSelection, ureq);
    if (lockedFiles.isEmpty()) {
      String msg = trans.translate("del.confirm") + "<p>" + fileSelection.renderAsHtml() + "</p>";   
      // create dialog controller
      dialogCtr = activateYesNoDialog(ureq, trans.translate("del.header"), msg, dialogCtr);
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.