Source Code Cross Referenced for XferLog.java in  » Net » DrFTPD » org » drftpd » plugins » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » DrFTPD » org.drftpd.plugins 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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.plugins;
019:
020:        import java.io.File;
021:        import java.io.FileOutputStream;
022:        import java.io.IOException;
023:        import java.io.PrintStream;
024:        import java.text.SimpleDateFormat;
025:        import java.util.Date;
026:        import java.util.Locale;
027:
028:        import net.sf.drftpd.FatalException;
029:        import net.sf.drftpd.event.Event;
030:        import net.sf.drftpd.event.FtpListener;
031:        import net.sf.drftpd.event.TransferEvent;
032:
033:        /**
034:         * @see http://www.wu-ftpd.org/man/xferlog.html
035:         * @author mog
036:         * @version $Id: XferLog.java 1238 2005-09-02 11:54:26Z zubov $
037:         */
038:        public class XferLog extends FtpListener {
039:            /**
040:             * xferlog.log - Contains all the upload/download information for all files
041:                      transferred (if logging of that is enabled). The format is the
042:                      following: current time, transfer time, user's hostname, number
043:                      of bytes sent, filename, 'a' if transfer was in ASCII mode or
044:                      'b' if BINARY, _ (meaningless), 'i' if incoming (user uploading)
045:                      or 'o' if outgoing (user downloading), 'r' (no meaning), user's
046:                      name, user's group, 1 if user had ident or 0 if not, user's ident
047:
048:                          current-time   transfer-time   remote-host    file-
049:                      size    filename    transfer-type   special-action-
050:                      flag   direction    access-mode    username    ser?
051:                      vice-name    authentication-method   authenticated-
052:                      user-id   completion-status
053:
054:            example lines:
055:            Mon Aug 11 14:03:30 2003 20 hostname 15000000 /path/to/file b _ i r user group 0 *
056:            Mon Aug 11 14:03:31 2003 33 hostname 15000000 /path/to/file b _ i r user group 1 user
057:            Mon Aug 11 14:03:44 2003 13 hostname 15000000 /path/to/file b _ i r user group 0 *
058:             */
059:            public static SimpleDateFormat DATE_FMT = new SimpleDateFormat(
060:                    "EEE MMM d HH:mm:ss yyyy", Locale.ENGLISH);
061:            private PrintStream _out;
062:
063:            public XferLog() {
064:                super ();
065:                new File("logs").mkdirs();
066:
067:                try {
068:                    //APPEND
069:                    _out = new PrintStream(new FileOutputStream("logs/xferlog",
070:                            true));
071:                } catch (IOException e) {
072:                    throw new FatalException(e);
073:                }
074:            }
075:
076:            public void actionPerformed(Event event) {
077:                if (event instanceof  TransferEvent) {
078:                    actionPerformed((TransferEvent) event);
079:                }
080:            }
081:
082:            public void actionPerformed(TransferEvent event) {
083:                char direction;
084:
085:                if (event.getCommand().equals("STOR")) {
086:                    direction = 'i';
087:                } else if (event.getCommand().equals("RETR")) {
088:                    direction = 'o';
089:                } else {
090:                    return;
091:                }
092:
093:                char transferType;
094:
095:                if (event.getType() == 'I') { // IMAGE
096:                    transferType = 'b';
097:                } else if (event.getType() == 'A') { // ASCII
098:                    transferType = 'a';
099:                } else {
100:                    throw new FatalException("Invalid transfer type");
101:                }
102:
103:                //char completed = event.isComplete() ? 'c' : 'i';
104:                // all transfers are noted as complete
105:                char completed = 'c';
106:                _out.println(DATE_FMT.format(new Date(event.getTime())) + " "
107:                        + (event.getDirectory().getXfertime() / 1000) + " "
108:                        + event.getPeer().getHostName() + " "
109:                        + event.getDirectory().length() + " "
110:                        + event.getDirectory().getPath() + " " + transferType
111:                        + " _ " + direction + " r " + event.getUser().getName()
112:                        + " " + event.getUser().getGroup() + " 0 * " // authentication-method   authenticated-user-id
113:                        + completed);
114:            }
115:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.