Examples of VFSItem


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

   * Check if resource can be copied (delegation to VFS item)
   * @param name
   * @return true: can copy; false: can not copy
   */
  public boolean canCopy(String name) {
    VFSItem item = resolveFile(name);
    if (item != null && VFSConstants.YES.equals(item.canCopy())) return true;
    else return false;
  }
View Full Code Here

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

   * @param name
   * @return true: can write; false: can not write
   */
  public boolean canWrite(String name) {
    // resolve item if it already exists
    VFSItem item = resolveFile(name);
    if (item == null) {
      // try to resolve parent in case the item does not yet exist
      int lastSlash = name.lastIndexOf("/");
      if (lastSlash > 0) {
        String containerName = name.substring(0, lastSlash);
        item = resolveFile(containerName);
      }
    }
    if (item == null) return false;
   
    VFSStatus status;
    if (item instanceof VFSContainer) {
      status = item.canWrite();
    } else {
      // read/write is not defined on item level, only on directory level
      status = item.getParentContainer().canWrite();
    }
    return VFSConstants.YES.equals(status);
  }
View Full Code Here

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

   * Check if resource can be deleted (delegation to VFS item)
   * @param name
   * @return true: can delete; false: can not delete
   */
  public boolean canDelete(String name) {
    VFSItem item = resolveFile(name);
    if (item != null && VFSConstants.YES.equals(item.canDelete())) {
      return !MetaInfoHelper.isLocked(item, userSession);
    }
    else return false;
  }
View Full Code Here

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

   * Check if resource can be renamed (delegation to VFS item)
   * @param name
   * @return true: can rename; false: can not rename
   */
  public boolean canRename(String name) {
    VFSItem item = resolveFile(name);
    if (item != null && VFSConstants.YES.equals(item.canRename())) {
      return !MetaInfoHelper.isLocked(item, userSession);
    }
    else return false;
 
View Full Code Here

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

   * @exception NameNotFoundException if an intermediate context does not exist
   * @exception NamingException if a naming exception is encountered
   */
  public void unbind(String name) throws NamingException {

    VFSItem file = resolveFile(name);
    if (file == null) throw new NamingException(smgr.getString("resources.notFound", name));

    VFSStatus status = file.delete();
    if (status == VFSConstants.NO)
      throw new NamingException(smgr.getString("resources.unbindFailed", name));
  }
View Full Code Here

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

  }

  @Override
  public boolean restore(VFSContainer container, VFSRevision revision) {
    String filename = revision.getName();
    VFSItem restoredItem = container.resolve(filename);
    if (restoredItem == null) {
      restoredItem = container.createChildLeaf(filename);
    }
    if (restoredItem instanceof VFSLeaf) {
      VFSLeaf restoredLeaf = (VFSLeaf) restoredItem;
View Full Code Here

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

   * @exception NameAlreadyBoundException if newName is already bound
   * @exception NamingException if a naming exception is encountered
   */
  public void rename(String oldName, String newName) throws NamingException {

    VFSItem oldFile = resolveFile(oldName);
    if (oldFile == null) throw new NamingException(smgr.getString("resources.notFound", oldName));

    VFSItem newFile = resolveFile(newName);
    if (newFile != null)
      throw new NameAlreadyBoundException();
   
    VFSStatus status = oldFile.rename(newName);
    if (status == VFSConstants.NO)
View Full Code Here

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

   *         context. Each element of the enumeration is of type NameClassPair.
   * @exception NamingException if a naming exception is encountered
   */
  public NamingEnumeration<NameClassPair> list(String name) throws NamingException {

    VFSItem file = resolveFile(name);
    if (file == null) throw new NamingException(smgr.getString("resources.notFound", name));
    return new NamingContextEnumeration(list(file).iterator());

  }
View Full Code Here

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

   * @exception NamingException if a naming exception is encountered
   */
  public Attributes getAttributes(String name, String[] attrIds) throws NamingException {

    // Building attribute list
    VFSItem file = resolveFile(name);
    if (file == null) throw new NamingException(smgr.getString("resources.notFound", name));
    return new VFSResourceAttributes(file);

  }
View Full Code Here

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

   * @exception NamingException if a naming exception is encountered
   */
  public void bind(String name, Object obj, Attributes attrs) throws NamingException {

    // Note: No custom attributes allowed
    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);
    VFSLeaf childLeaf = ((VFSContainer)folder).createChildLeaf(newName);
    if (childLeaf == null)
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.