KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > drftpd > remotefile > LinkedRemoteFileInterface


1 /*
2  * This file is part of DrFTPD, Distributed FTP Daemon.
3  *
4  * DrFTPD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * DrFTPD is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with DrFTPD; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18 package net.sf.drftpd.remotefile;
19
20 import java.io.FileNotFoundException JavaDoc;
21 import java.io.IOException JavaDoc;
22 import java.util.Collection JavaDoc;
23 import java.util.Map JavaDoc;
24 import java.util.Set JavaDoc;
25
26 import net.sf.drftpd.FileExistsException;
27 import net.sf.drftpd.NoAvailableSlaveException;
28 import net.sf.drftpd.ObjectNotFoundException;
29 import net.sf.drftpd.SFVFile;
30 import net.sf.drftpd.master.RemoteSlave;
31 import net.sf.drftpd.remotefile.LinkedRemoteFile.NonExistingFile;
32 import net.sf.drftpd.slave.Transfer;
33 import net.sf.drftpd.slave.TransferStatus;
34
35 /**
36  * @author mog
37  *
38  * To change the template for this generated type comment go to
39  * Window>Preferences>Java>Code Generation>Code and Comments
40  */

41 public interface LinkedRemoteFileInterface extends RemoteFileInterface {
42     /**
43      * Updates lastMofidied() on this directory, use putFile() to avoid it.
44      */

45     public abstract LinkedRemoteFile addFile(AbstractRemoteFile file);
46     public abstract void addSlave(RemoteSlave slave);
47     /**
48      * @throws ClassCastException if object is not an instance of RemoteFileInterface.
49      * @see java.lang.Comparable#compareTo(java.lang.Object)
50      */

51     public abstract int compareTo(Object JavaDoc o);
52     public abstract LinkedRemoteFile createDirectories(String JavaDoc path);
53     public abstract LinkedRemoteFile createDirectory(String JavaDoc fileName)
54         throws FileExistsException;
55     public abstract LinkedRemoteFile createDirectory(
56         String JavaDoc owner,
57         String JavaDoc group,
58         String JavaDoc fileName)
59         throws FileExistsException;
60     /**
61      * Deletes a file or directory, if slaves are offline, the file cannot be deleted.
62      * To work around this, the file gets a deleted flag set and when the offline slave is remerge()'d, it is deleted from the slave and delete() is called again.
63      *
64      * Trying to lookupFile() or getFile() a deleted file throws FileNotFoundException.
65      */

66     public abstract void delete();
67     /**
68      * This method will delete files off of slaves not contained in the destSlaves Set
69      */

70     public abstract void deleteOthers(Set JavaDoc destSlaves);
71     public abstract long dirSize();
72     public abstract Collection JavaDoc getAvailableSlaves()
73         throws NoAvailableSlaveException;
74     /**
75      * Uses cached checksum if the cached checksum is not 0
76      */

77     public abstract long getCheckSum() throws NoAvailableSlaveException;
78     /**
79      * Returns 0 if the checksum cannot be read.
80      */

81     public abstract long getCheckSumFromSlave()
82         throws NoAvailableSlaveException, IOException JavaDoc;
83     public abstract Collection JavaDoc getDirectories();
84     /**
85      * Returns fLinkedRemoteFileInterfaced in this directory.
86      *
87      * @param fileName
88      * @throws FileNotFoundException if fileName doesn't exist in the files Map
89      */

90     public abstract LinkedRemoteFileInterface getFile(String JavaDoc fileName)
91         throws FileNotFoundException JavaDoc;
92     public abstract LinkedRemoteFileInterface getFileDeleted(
93         String JavaDoc fileName)
94         throws FileNotFoundException JavaDoc;
95
96     /**
97      * Returns the underlying Map for this directory.
98      *
99      * It is dangerous to modify without knowing what you're doing.
100      * Dirsize needs to be taken into account as well as sending approperiate commands to the slaves.
101      * @return the underlying Map for this directory.
102      */

103     public abstract Map JavaDoc getMap();
104     public abstract LinkedRemoteFileInterface getOldestFile()
105         throws ObjectNotFoundException;
106     public abstract LinkedRemoteFile getParentFile()
107         throws FileNotFoundException JavaDoc;
108     public abstract LinkedRemoteFile getParentFileNull();
109     public abstract LinkedRemoteFile getRoot();
110     public abstract SFVFile getSFVFile()
111         throws IOException JavaDoc, FileNotFoundException JavaDoc, NoAvailableSlaveException;
112     public abstract long getXferspeed();
113     /**
114      * Returns true if this directory contains a file named filename, this is case sensitive.
115      * @param filename The name of the file
116      * @return true if this directory contains a file named filename, this is case sensitive.
117      */

118     public abstract boolean hasFile(String JavaDoc filename);
119     public abstract int hashCode();
120     /**
121      * Returns true if this file or directory uses slaves that are currently offline.
122      * @return true if this file or directory uses slaves that are currently offline.
123      */

124     public abstract boolean hasOfflineSlaves();
125     public abstract boolean hasSlave(RemoteSlave slave);
126     /**
127      * Does file have online slaves?
128      *
129      * @return Always true for directories
130      */

131     public abstract boolean isAvailable();
132     public abstract LinkedRemoteFile lookupFile(String JavaDoc path)
133         throws FileNotFoundException JavaDoc;
134     public abstract LinkedRemoteFile lookupFile(
135         String JavaDoc path,
136         boolean includeDeleted)
137         throws FileNotFoundException JavaDoc;
138     public abstract NonExistingFile lookupNonExistingFile(String JavaDoc path);
139     public abstract NonExistingFile lookupNonExistingFile(
140         String JavaDoc path,
141         boolean includeDeleted);
142     /**
143      * Returns path for a non-existing file. Performs path normalization and returns an absolute path
144      */

145     public abstract String JavaDoc lookupPath(String JavaDoc path);
146     public abstract SFVFile lookupSFVFile()
147         throws IOException JavaDoc, FileNotFoundException JavaDoc, NoAvailableSlaveException;
148     /**
149      * Use addFile() if you want lastModified to be updated.
150      */

151     public abstract LinkedRemoteFile putFile(RemoteFileInterface file);
152
153     public TransferStatus receiveFile(Transfer transfer, char type, long offset) throws IOException JavaDoc;
154     /**
155      * Merges mergedir directory onto <code>this</code> directories.
156      * If duplicates exist, the slaves are added to this object and the file-attributes of the oldest file (lastModified) are kept.
157      */

158     public abstract void remerge(LinkedRemoteFile mergedir, RemoteSlave rslave);
159     public abstract boolean removeSlave(RemoteSlave slave);
160     /**
161      * Renames this file
162      */

163     public abstract LinkedRemoteFile renameTo(String JavaDoc toDirPath, String JavaDoc toName)
164         throws IOException JavaDoc, FileNotFoundException JavaDoc;
165     public TransferStatus sendFile(Transfer transfer, char type, long offset) throws IOException JavaDoc;
166     public abstract void setCheckSum(long checkSum);
167     public abstract void setGroup(String JavaDoc group);
168     public abstract void setLastModified(long lastModified);
169     public abstract void setLength(long length);
170     public abstract void setOwner(String JavaDoc owner);
171     public abstract void setXfertime(long xfertime);
172     public abstract String JavaDoc toString();
173     public abstract void unmergeDir(RemoteSlave rslave);
174     public abstract void unmergeFile(RemoteSlave rslave);
175 }
Popular Tags