⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abstractdavresource.java

📁 这是linux下ssl vpn的实现程序
💻 JAVA
字号:
/*
 *  SSL-Explorer
 *
 *  Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2 of
 *  the License, or (at your option) any later version.
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public
 *  License along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
			
package com.sslexplorer.vfs.webdav;

import java.io.IOException;
import java.net.URI;
import java.util.Date;
import java.util.Iterator;

import org.apache.commons.vfs.FileObject;

import com.sslexplorer.boot.Util;
import com.sslexplorer.vfs.webdav.methods.GET;

/**
 * @author Brett Smith <brett@3sp.com>
 */
public abstract class AbstractDAVResource implements DAVResource {
    
    private boolean collection;
    private String name;
    private DAVResource parent;
    private URI relativeUri;
    protected DAVTransaction transaction;

    /**
     * 
     */
    public AbstractDAVResource(URI relativeUri, boolean collection, String name, DAVResource parent) {
        super();
        this.collection = collection;     
        this.name = name;
        this.parent = parent;
        this.relativeUri = relativeUri;
    }
    
    public boolean isMount() {
    	return true;
    }

    public void verifyAccess() {
    		
    }
    public Iterator getChildren() throws IOException, DAVAuthenticationRequiredException {
        return null;
    }
    
    public String getWebFolderPath() {
    	return "";
    }

	public FileObject getFile() throws IOException{
		return null;
	}

    /* (non-Javadoc)
     * @see java.lang.Comparable#compareTo(java.lang.Object)
     */
    public int compareTo(Object object) {
        return toString().compareTo(object.toString());
    }

    /* (non-Javadoc)
     * @see org.betaversion.webdav.DAVResource#isCollection()
     */
    public boolean isCollection() {
        return collection;
    }

    /* (non-Javadoc)
     * @see org.betaversion.webdav.DAVResource#isResource()
     */
    public boolean isResource() {
        return !isCollection();
    }

    /* (non-Javadoc)
     * @see org.betaversion.webdav.DAVResource#getMount()
     */
    public DAVMount getMount() {
        return null;
    }

    /* (non-Javadoc)
     * @see org.betaversion.webdav.DAVResource#getDisplayName()
     */
    public String getDisplayName() {
        String name = this.name;
        if (isCollection()) return (name + "/");
        return name;
    }

    /* (non-Javadoc)
     * @see org.betaversion.webdav.DAVResource#getRelativePath()
     */
    public String getRelativePath() {
        return getRelativeURI().getPath();
    }

    /* (non-Javadoc)
     * @see org.betaversion.webdav.DAVResource#getRelativeURI()
     */
    public URI getRelativeURI() {
        return relativeUri;
    }

    /**
     * <p>
     * Return the parent {@link DAVResource} of this instance.
     * </p>
     * 
     * @return a <b>non-null</b> {@link DAVResource} instance or <b>null</b>
     *         if this {@link DAVResource} is the repository root.
     */
    public DAVResource getParent() {
        try {
            if(parent == null) {
                String parentPath = DAVUtilities.stripLeadingSlash(DAVUtilities.getParentPath(getFullPath()));
                if(parentPath == null || parentPath.equals("/")) {
                    return null;
                }
                else {
                    return DAVRepository.getInstance().getResource(parentPath, transaction);
                }
            }
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
        return parent;
    }

    /* (non-Javadoc)
     * @see org.betaversion.webdav.DAVResource#getContentType()
     */
    public String getContentType() {
        if (this.isNull()) return null;
        if (this.isCollection()) return GET.COLLECTION_MIME_TYPE;
        String mime = DAVUtilities.getMimeType(this.getDisplayName());
        return mime == null ? "application/octet-stream" : mime;
    }

    /* (non-Javadoc)
     * @see org.betaversion.webdav.DAVResource#getContentLength()
     */
    public Long getContentLength() {
        return null;
    }

    /* (non-Javadoc)
     * @see org.betaversion.webdav.DAVResource#getLastModified()
     */
    public Date getLastModified() {
        return new Date();
    }

    /* (non-Javadoc)
     * @see org.betaversion.webdav.DAVResource#getEntityTag()
     */
    public String getEntityTag() {
        if (this.isNull()) return null;
        String path = this.getRelativePath();
        return DAVUtilities.getETAG(path, this.getLastModified());
    }

    /* (non-Javadoc)
     * @see org.betaversion.webdav.DAVResource#delete()
     */
    public void delete() throws DAVMultiStatus {
    }

    /* (non-Javadoc)
     * @see org.betaversion.webdav.DAVResource#copy(org.betaversion.webdav.DAVResource, boolean, boolean)
     */
    public void copy(DAVResource dest, boolean overwrite, boolean recursive) throws DAVMultiStatus {
    }

    /* (non-Javadoc)
     * @see org.betaversion.webdav.DAVResource#move(org.betaversion.webdav.DAVResource, boolean)
     */
    public void move(DAVResource dest, boolean overwrite) throws DAVMultiStatus {
    }

    /* (non-Javadoc)
     * @see org.betaversion.webdav.DAVResource#makeCollection()
     */
    public void makeCollection() {
    }

    /* (non-Javadoc)
     * @see org.betaversion.webdav.DAVResource#read()
     */
    public DAVInputStream read() {
        return null;
    }

    /* (non-Javadoc)
     * @see org.betaversion.webdav.DAVResource#write()
     */
    public DAVOutputStream write() {
        return null;
    }

    
    /* (non-Javadoc)
     * @see org.betaversion.webdav.DAVResource#isNull()
     */
    public boolean isNull() {
        return false;
    }
    
    /* (non-Javadoc)
     * @see org.betaversion.webdav.DAVResource#getBasename()
     */
    public String getBasename() {
        return name;
    }
    
    public void start(DAVTransaction transaction) {
        this.transaction = transaction;
    }

    public void stop() {
        transaction = null;
    }

    /* (non-Javadoc)
     * @see com.sslexplorer.vfs.webdav.DAVResource#getFullURI()
     */
    public URI getFullURI() {
        DAVMount mount = getMount(); 
        URI uri = URI.create( mount == null ? ( "/" + getRelativeURI() ) : ( "/" + DAVUtilities.encodePath(mount.getMountString(), true) + "/" + DAVUtilities.encodePath(getRelativePath(), true) ) );
        return uri;
    }
    
    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    public String toString() {
        return "Rel. URI = " + getRelativeURI() + ", Rel. Path = " + getRelativePath() + ", Name = " + name + " Mount = " + getMount().getMountString();
    }

    /* (non-Javadoc)
     * @see com.sslexplorer.vfs.webdav.DAVResource#getTransaction()
     */
    public DAVTransaction getTransaction() {
        return transaction;
    }

    /* (non-Javadoc)
     * @see com.sslexplorer.vfs.webdav.DAVResource#getFullPath()
     */
    public String getFullPath() {
        DAVMount mount = getMount(); 
        return mount == null ? ( "/" + getRelativeURI() ) : ( "/" + mount.getMountString() + "/" + getRelativePath());
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -