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 net.sf.drftpd.event;
019:
020: import org.drftpd.plugins.SiteBot;
021:
022: import org.drftpd.usermanager.User;
023:
024: import org.jdom.Element;
025:
026: import java.util.Iterator;
027: import java.util.List;
028: import java.util.Map;
029:
030: /**
031: * @author mog
032: *
033: * @version $Id: NukeEvent.java 820 2004-11-26 04:54:18Z mog $
034: */
035: public class NukeEvent extends UserEvent {
036: private int multiplier;
037: private long nukedAmount;
038: private Map nukees;
039: private String path;
040: private String reason;
041: private long size;
042:
043: public NukeEvent(User user, String command, String path, long size,
044: long nukedAmount, int multiplier, String reason, Map nukees) {
045: this (user, command, path, System.currentTimeMillis(), size,
046: nukedAmount, multiplier, reason, nukees);
047: }
048:
049: public NukeEvent(User user, String command, String path, long time,
050: long size, long nukedAmount, int multiplier, String reason,
051: Map nukees) {
052: super (user, command, time);
053: this .multiplier = multiplier;
054: this .reason = reason;
055: this .path = path;
056: this .nukees = nukees;
057: this .size = size;
058: this .nukedAmount = nukedAmount;
059: }
060:
061: public int getMultiplier() {
062: return multiplier;
063: }
064:
065: public long getNukedAmount() {
066: return nukedAmount;
067: }
068:
069: /**
070: * String username as key
071: * Integer debt as value
072: * @deprecated
073: */
074: public Map getNukees() {
075: return nukees;
076: }
077:
078: /**
079: * Returns a list of <code>net.sf.drftpd.Nukee</code> objects.
080: * @return a list of <code>net.sf.drftpd.Nukee</code> objects.
081: * @see net.sf.drftpd.Nukee
082: */
083: public List getNukees2() {
084: return SiteBot.map2nukees(nukees);
085: }
086:
087: public String getPath() {
088: return path;
089: }
090:
091: public String getReason() {
092: return reason;
093: }
094:
095: public long getSize() {
096: return size;
097: }
098:
099: public void setReason(String string) {
100: reason = string;
101: }
102:
103: public Element toJDOM() {
104: Element element = new Element("nuke");
105: element.addContent(new Element("user").setText(getUser()
106: .getName()));
107: element.addContent(new Element("path").setText(this .getPath()));
108: element.addContent(new Element("multiplier").setText(Integer
109: .toString(getMultiplier())));
110: element.addContent(new Element("reason").setText(this
111: .getReason()));
112: element.addContent(new Element("time").setText(Long
113: .toString(getTime())));
114:
115: element.addContent(new Element("size").setText(Long
116: .toString(getSize())));
117: element.addContent(new Element("nukedAmount").setText(Long
118: .toString(getNukedAmount())));
119:
120: Element nukees = new Element("nukees");
121:
122: for (Iterator iter = getNukees().entrySet().iterator(); iter
123: .hasNext();) {
124: Map.Entry entry = (Map.Entry) iter.next();
125: String username = (String) entry.getKey();
126: Long amount = (Long) entry.getValue();
127: Element nukee = new Element("nukee");
128: nukee.addContent(new Element("username").setText(username));
129: nukee.addContent(new Element("amount").setText(amount
130: .toString()));
131: nukees.addContent(nukee);
132: }
133:
134: element.addContent(nukees);
135:
136: return element;
137: }
138:
139: public String toString() {
140: return "[NUKE:" + getPath() + ",multiplier=" + getMultiplier()
141: + "]";
142: }
143:
144: public void setUser(User user) {
145: _user = user;
146: }
147: }
|