Examples of VFSItem


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

  public void rebind(String name, Object obj, Attributes attrs) throws NamingException {

    // Note: No custom attributes allowed
    // Check obj type

    VFSItem vfsItem = resolveFile(name);
    if (vfsItem == null || (!(vfsItem instanceof VFSLeaf))) throw new NamingException(smgr.getString("resources.bindFailed", name));
    VFSLeaf file = (VFSLeaf)vfsItem;
   
    if(file instanceof Versionable && ((Versionable)file).getVersions().isVersioned()) {
      VersionsManager.getInstance().addToRevisions((Versionable)file, identity, "");
View Full Code Here

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

   *              mandatory attributes required for creation
   * @exception NamingException if a naming exception is encountered
   */
  public DirContext createSubcontext(String name, Attributes attrs) throws NamingException {

    VFSItem file = resolveFile(name);
    if (file != null) throw new NameAlreadyBoundException(smgr.getString("resources.alreadyBound", name));
   
    int lastSlash = name.lastIndexOf('/');
    if (lastSlash == -1) throw new NamingException();
    String parent = name.substring(0, lastSlash);
    VFSItem folder = resolveFile(parent);
    if (folder == null || (!(folder instanceof VFSContainer)))
      throw new NamingException(smgr.getString("resources.bindFailed", name));
    String newName = name.substring(lastSlash + 1);
    VFSItem childContainer = ((VFSContainer)folder).createChildContainer(newName);
    if (childContainer == null)
      throw new NamingException(smgr.getString("resources.bindFailed", name));
    return (DirContext)lookup(name);

  }
View Full Code Here

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

   *            path will start from this relativeBasePath
   * @return
   */
  public static String getSelectedRelativeItemPath(FileChoosenEvent event, VFSContainer rootContainer, String relativeBasePath) {
    // 1) Create path absolute to the root container
    VFSItem selectedItem = event.getSelectedItem();
    if (selectedItem == null) return null;
    String absPath = "";
    VFSItem tmpItem = selectedItem;   
    // Check for merged containers to fix problems with named containers, see OLAT-3848
    List<NamedContainerImpl> namedRootChilds = new ArrayList<NamedContainerImpl>();
    for (VFSItem rootItem : rootContainer.getItems()) {
      if (rootItem instanceof NamedContainerImpl) {
        namedRootChilds.add((NamedContainerImpl) rootItem);
      }
    }
    // Check if root container is the same as the item and vice versa. It is
    // necessary to perform the check on both containers to catch all potential
    // cases with MergedSource and NamedContainer where the check in one
    // direction is not necessarily the same as the opposite check
    while ( tmpItem != null && !rootContainer.isSame(tmpItem) && !tmpItem.isSame(rootContainer)) {
      String itemFileName = tmpItem.getName();
      // Special case: check if this is a named container, see OLAT-3848
      for (NamedContainerImpl namedRootChild : namedRootChilds) {
        if (namedRootChild.isSame(tmpItem)) {
          itemFileName = namedRootChild.getName();
        }
      }
      absPath = "/" + itemFileName + absPath;
      tmpItem = tmpItem.getParentContainer();
    }
   
    if (relativeBasePath == null) {
      return absPath;
    }
View Full Code Here

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

  @SuppressWarnings("unchecked")
  @Override
  public List<AjaxTreeNode> getChildrenFor(String nodePath) {
    List<AjaxTreeNode> childNodes = new ArrayList<AjaxTreeNode>();
    // get item for given path
    VFSItem item;
    if (rootContainer.getName().equals(nodePath)) {
      item = rootContainer;
      nodePath = ""; // start empty
    } else {
      // replace node delimiter with file system delimiter
View Full Code Here

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

   * @param treeNodeId
   * @return
   */
  public VFSItem resolveFileForTreeNodeId(String treeNodeId) {
    String relFilePath = treeNodeId.replace(DELIMITER_NODE, DELIMITER_FILESYSTEM);
    VFSItem item = VFSManager.resolveFile(rootContainer, relFilePath);
    return item;
  }
View Full Code Here

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

  }
  @SuppressWarnings("unused")
  private Mapper createMapper(final VFSContainer rootContainer) {
    Mapper map = new Mapper() {
      public MediaResource handle(String relPath,HttpServletRequest request) {
        VFSItem currentItem = rootContainer.resolve(relPath);
        if (currentItem == null || (currentItem instanceof VFSContainer)) {
          return new NotFoundMediaResource(relPath);
        }
        return new VFSMediaResource((VFSLeaf)currentItem);
      }
View Full Code Here

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

        if (!path.equals("")) {
          if (log.isDebug()) log.debug("direct navigation to container-path=" + dirPath);
          folderComponent.setCurrentContainerPath(dirPath);
        }
      }
      VFSItem vfsItem = folderComponent.getRootContainer().resolve(path.endsWith("/") ? path.substring(0, path.length()-1) : path);
      if (!(vfsItem instanceof VFSContainer)) {
        // could be a file - create the mapper - otherwise don't create one if it's a directory
       
        // Create a mapper to deliver the auto-download of the file. We have to
        // create a dedicated mapper here
View Full Code Here

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

   
    @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.VFSItem

          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.VFSItem

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