Package org.olat.core.util.vfs.version

Examples of org.olat.core.util.vfs.version.Versions


    // asume full access unless security callback tells us something different.
    boolean canWrite = child.getParentContainer().canWrite() == VFSConstants.YES;
    boolean canDelete = child.getParentContainer().canDelete() == VFSConstants.YES;
    boolean isAbstract = (child instanceof AbstractVirtualContainer);

    Versions versions = null;
    if(canContainerVersion && child instanceof Versionable) {
      Versionable versionable = (Versionable)child;
      if(versionable.getVersions().isVersioned()) {
        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) {
      sb.append(translator.translate("Directory"));
    }
    else {
      if (type.equals(TYPE_FILE)) {
        sb.append(translator.translate("UnknownFile"));
      }
      else {
        sb.append(type.toUpperCase());
        sb.append(" ").append(translator.translate(TYPE_FILE));
      }
    }
    sb.append("</td><td>");
   
    if(canContainerVersion) {
      if (canVersion)
        sb.append(versions.getRevisionNr());
      sb.append("</td><td>");
    }
   
    // last modified
    long lastModified = child.getLastModified();
View Full Code Here


      }
      return "-";
    }

    public String getComment() {
      Versions versions = ((Versionable)versionFile).getVersions();
      String comment = versions.getComment();
      if (StringHelper.containsNonWhitespace(comment)) {
        return comment;
      } else if ("1".equals(versions.getRevisionNr())) {
        return getTranslator().translate("version.initialRevision");
      }
      return "";
    }
View Full Code Here

    public int getRowCount() {
      return versionList.size();
    }

    public Object getValueAt(int row, int col) {
      Versions versioned = versionList.get(row);
      switch (col) {
        case 0: {
          VFSRevision lastRevision = getLastRevision(versioned);
          return lastRevision == null ? null : lastRevision.getName();
        }
        case 1:
          return versioned.getCreator();
        case 2: {
          VFSRevision lastRevision = getLastRevision(versioned);
          return lastRevision == null ? null : lastRevision.getAuthor();
        }
        case 3: {
View Full Code Here

            listenTo(lockedFileDialog);
            lockedFileDialog.activate();
          }
          else if (existingVFSItem instanceof Versionable && ((Versionable)existingVFSItem).getVersions().isVersioned()) {
            Versionable versionable = (Versionable)existingVFSItem;
            Versions versions = versionable.getVersions();
            String relPath = null;
            if(existingVFSItem instanceof OlatRootFileImpl) {
              relPath = ((OlatRootFileImpl)existingVFSItem).getRelPath();
            }
            int maxNumOfRevisions = FolderConfig.versionsAllowed(relPath);
            if(maxNumOfRevisions == 0) {
              //it's possible if someone change the configuration
              // let calling method decide what to do.
              overwriteDialog = DialogBoxUIFactory.createGenericDialog(ureq, getWindowControl(), translate("ul.overwrite.threeoptions.title"), translate("ul.overwrite.threeoptions.text", new String[] {existingVFSItem.getName(), renamedFilename} ), asList(translate("ul.overwrite.threeoptions.overwrite"), translate("ul.overwrite.threeoptions.rename", renamedFilename), translate("ul.overwrite.threeoptions.cancel")));
              listenTo(overwriteDialog);
              overwriteDialog.activate();
            } else if(versions.getRevisions().isEmpty() || maxNumOfRevisions < 0 || maxNumOfRevisions > versions.getRevisions().size()) {
              // let calling method decide what to do.
              overwriteDialog = DialogBoxUIFactory.createGenericDialog(ureq, getWindowControl(), translate("ul.overwrite.threeoptions.title"), translate("ul.versionoroverwrite", new String[] {existingVFSItem.getName(), renamedFilename} ), asList(translate("ul.overwrite.threeoptions.newVersion"), translate("ul.overwrite.threeoptions.rename", renamedFilename), translate("ul.overwrite.threeoptions.cancel")));
              listenTo(overwriteDialog);
              overwriteDialog.activate();
            } else {
            //delete first some old revisions
              String title = translate("ul.tooManyRevisions.title", new String[]{Integer.toString(maxNumOfRevisions), Integer.toString(versions.getRevisions().size())});
              String description = translate("ul.tooManyRevisions.description", new String[]{Integer.toString(maxNumOfRevisions), Integer.toString(versions.getRevisions().size())});
              revisionListCtr = new RevisionListController(ureq, getWindowControl(), versionable, title, description);
              listenTo(revisionListCtr);
              revisionListDialogBox = new CloseableModalController(getWindowControl(), translate("delete"), revisionListCtr.getInitialComponent());
              revisionListDialogBox.activate();
            }
View Full Code Here

      } else {
        if (existingVFSItem instanceof Versionable && ((Versionable)existingVFSItem).getVersions().isVersioned()) {
          cleanUpRevisionDialog();
 
          Versionable versionable = (Versionable)existingVFSItem;
          Versions versions = versionable.getVersions();
          int maxNumOfRevisions = FolderConfig.versionsAllowed(null);
          if(maxNumOfRevisions < 0 || maxNumOfRevisions > versions.getRevisions().size()) {
            commentVersionCtr = new VersionCommentController(ureq,getWindowControl(), askForLock(existingVFSItem, ureq), true);
            listenTo(commentVersionCtr);
            commentVersionDialogBox = new CloseableModalController(getWindowControl(), translate("save"), commentVersionCtr.getInitialComponent());
            commentVersionDialogBox.activate();
          } else {
View Full Code Here

TOP

Related Classes of org.olat.core.util.vfs.version.Versions

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.