001: /*
002: * This file is part of DrFTPD, Distributed FTP Daemon.
003: *
004: * DrFTPD is free software; you can redistribute it and/or modify
005: * it under the terms of the GNU General Public License as published by
006: * the Free Software Foundation; either version 2 of the License, or
007: * (at your option) any later version.
008: *
009: * DrFTPD is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU General Public License for more details.
013: *
014: * You should have received a copy of the GNU General Public License
015: * along with DrFTPD; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: */
018: package org.drftpd.remotefile;
019:
020: import java.io.FileNotFoundException;
021: import java.io.IOException;
022: import java.util.Collection;
023: import java.util.List;
024: import java.util.Map;
025: import java.util.Set;
026:
027: import net.sf.drftpd.FileExistsException;
028: import net.sf.drftpd.NoAvailableSlaveException;
029:
030: import org.drftpd.SFVFile;
031: import org.drftpd.master.RemoteSlave;
032: import org.drftpd.remotefile.LinkedRemoteFile.NonExistingFile;
033:
034: /**
035: * @author mog
036: * @version $Id: LinkedRemoteFileInterface.java 1513 2006-10-13 22:41:08Z tdsoul $
037: *
038: */
039: public interface LinkedRemoteFileInterface extends RemoteFileInterface {
040: /**
041: * Updates lastMofidied() on this directory, use putFile() to avoid it.
042: */
043: public abstract LinkedRemoteFile addFile(RemoteFileInterface file);
044:
045: public abstract void addSlave(RemoteSlave slave);
046:
047: /**
048: * @throws ClassCastException if object is not an instance of RemoteFileInterface.
049: * @see java.lang.Comparable#compareTo(java.lang.Object)
050: */
051: public abstract int compareTo(Object o);
052:
053: public abstract LinkedRemoteFile createDirectories(String path);
054:
055: public abstract LinkedRemoteFile createDirectory(String fileName)
056: throws FileExistsException;
057:
058: public abstract LinkedRemoteFile createDirectory(String owner,
059: String group, String fileName) throws FileExistsException;
060:
061: /**
062: * Deletes a file or directory, if slaves are offline, the file cannot be deleted.
063: * 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.
064: *
065: * Trying to lookupFile() or getFile() a deleted file throws FileNotFoundException.
066: */
067: public abstract void delete();
068:
069: public abstract long dirSize();
070:
071: public abstract Collection<RemoteSlave> getAvailableSlaves()
072: throws NoAvailableSlaveException;
073:
074: /**
075: * Uses cached checksum if the cached checksum is not 0
076: */
077: public abstract long getCheckSum() throws NoAvailableSlaveException;
078:
079: /**
080: * Returns 0 if the checksum cannot be read.
081: */
082: public abstract long getCheckSumFromSlave()
083: throws NoAvailableSlaveException, IOException;
084:
085: public abstract Collection<LinkedRemoteFileInterface> getDirectories();
086:
087: /**
088: * Returns fLinkedRemoteFileInterfaced in this directory.
089: *
090: * @param fileName
091: * @throws FileNotFoundException if fileName doesn't exist in the files Map
092: */
093: public abstract LinkedRemoteFileInterface getFile(String fileName)
094: throws FileNotFoundException;
095:
096: /**
097: * Returns the underlying Map for this directory.
098: *
099: * 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 getMap();
104:
105: public abstract LinkedRemoteFile getParentFile()
106: throws FileNotFoundException;
107:
108: public abstract LinkedRemoteFile getParentFileNull();
109:
110: public abstract LinkedRemoteFile getRoot();
111:
112: public abstract SFVFile getSFVFile() throws IOException,
113: FileNotFoundException, NoAvailableSlaveException,
114: FileStillTransferringException;
115:
116: public abstract long getXferspeed();
117:
118: /**
119: * Returns true if this directory contains a file named filename, this is case sensitive.
120: * @param filename The name of the file
121: * @return true if this directory contains a file named filename, this is case sensitive.
122: */
123: public abstract boolean hasFile(String filename);
124:
125: public abstract int hashCode();
126:
127: /**
128: * Returns true if this file or directory uses slaves that are currently offline.
129: * @return true if this file or directory uses slaves that are currently offline.
130: */
131: public abstract boolean hasOfflineSlaves();
132:
133: public abstract boolean hasSlave(RemoteSlave slave);
134:
135: /**
136: * Does file have online slaves?
137: *
138: * @return Always true for directories
139: */
140: public abstract boolean isAvailable();
141:
142: /**
143: * Is file removed from all slaves?
144: */
145: public abstract boolean isDeleted();
146:
147: public abstract LinkedRemoteFile lookupFile(String path)
148: throws FileNotFoundException;
149:
150: public abstract LinkedRemoteFile lookupFile(String path,
151: boolean followLinks) throws FileNotFoundException;
152:
153: public abstract NonExistingFile lookupNonExistingFile(String path);
154:
155: public abstract NonExistingFile lookupNonExistingFile(String path,
156: boolean followLinks);
157:
158: /**
159: * Returns path for a non-existing file. Performs path normalization and returns an absolute path
160: */
161: public abstract String lookupPath(String path);
162:
163: public abstract SFVFile lookupSFVFile() throws IOException,
164: FileNotFoundException, NoAvailableSlaveException,
165: FileStillTransferringException;
166:
167: /**
168: * Use addFile() if you want lastModified to be updated.
169: */
170: public abstract LinkedRemoteFile putFile(RemoteFileInterface file);
171:
172: /**
173: * Merges mergedir directory onto <code>this</code> directories.
174: * If duplicates exist, the slaves are added to this object and the file-attributes of the oldest file (lastModified) are kept.
175: */
176: public abstract void remerge(
177: CaseInsensitiveHashtable lightRemoteFiles,
178: RemoteSlave rslave) throws IOException;
179:
180: public abstract boolean removeSlave(RemoteSlave slave);
181:
182: /**
183: * Renames this file
184: */
185: public abstract void renameTo(String toDirPath, String toName)
186: throws IOException, FileNotFoundException;
187:
188: public abstract void setCheckSum(long checkSum);
189:
190: public abstract void setGroup(String group);
191:
192: public abstract void setLastModified(long lastModified);
193:
194: public abstract void setLength(long length);
195:
196: public abstract void setOwner(String owner);
197:
198: public abstract long getXfertime();
199:
200: public abstract void setXfertime(long xfertime);
201:
202: public abstract String toString();
203:
204: public abstract void unmergeDir(RemoteSlave rslave);
205:
206: public abstract void unmergeFile(RemoteSlave rslave);
207:
208: public abstract void deleteFromSlave(RemoteSlave rslave);
209:
210: public abstract Collection<LinkedRemoteFileInterface> getFiles2();
211:
212: public abstract List<LinkedRemoteFileInterface> getAllParentFiles();
213:
214: /**
215: * @return
216: */
217: public abstract boolean isValid();
218: }
|