Source Code Cross Referenced for SvnUtils.java in  » Issue-Tracking » jTrac » info » jtrac » util » 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 » Issue Tracking » jTrac » info.jtrac.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2002-2005 the original author or authors.
003:         * 
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         * 
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package info.jtrac.util;
018:
019:        import java.util.Collection;
020:        import java.util.Date;
021:        import java.util.Map;
022:        import java.util.TreeMap;
023:        import org.tmatesoft.svn.core.SVNLogEntry;
024:        import org.tmatesoft.svn.core.SVNNodeKind;
025:        import org.tmatesoft.svn.core.SVNURL;
026:        import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
027:        import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
028:        import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl;
029:        import org.tmatesoft.svn.core.io.SVNRepository;
030:        import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
031:        import org.tmatesoft.svn.core.wc.SVNWCUtil;
032:
033:        /**
034:         * Utilities that talk to and get data from a Subversion repository
035:         * using the JavaSvn library
036:         */
037:        public class SvnUtils {
038:
039:            public static SVNRepository getRepository(String url,
040:                    String username, String password) {
041:                DAVRepositoryFactory.setup();
042:                SVNRepositoryFactoryImpl.setup();
043:                SVNRepository repository = null;
044:                SVNNodeKind nodeKind = null;
045:                try {
046:                    repository = SVNRepositoryFactory.create(SVNURL
047:                            .parseURIEncoded(url));
048:                    ISVNAuthenticationManager authManager = SVNWCUtil
049:                            .createDefaultAuthenticationManager(username,
050:                                    password);
051:                    repository.setAuthenticationManager(authManager);
052:                    nodeKind = repository.checkPath("", -1);
053:                } catch (Exception e) {
054:                    throw new RuntimeException(e);
055:                }
056:                if (nodeKind == SVNNodeKind.NONE) {
057:                    throw new RuntimeException("There is no entry at '" + url
058:                            + "'.");
059:                } else if (nodeKind == SVNNodeKind.FILE) {
060:                    throw new RuntimeException("The entry at '" + url
061:                            + "' is a file while a directory was expected.");
062:                }
063:                return repository;
064:            }
065:
066:            public static Map<String, Integer> getCommitsPerCommitter(
067:                    SVNRepository repository) {
068:                Collection<SVNLogEntry> svnLogEntries = null;
069:                try {
070:                    svnLogEntries = repository.log(new String[] { "" }, null,
071:                            0, repository.getLatestRevision(), true, true);
072:                } catch (Exception e) {
073:                    throw new RuntimeException(e);
074:                }
075:                Date createdDate = null;
076:                long now = new Date().getTime();
077:                long commits = 0;
078:                Map<String, Integer> commitsPerCommitter = new TreeMap<String, Integer>();
079:                Map<String, Integer> commitsPerFile = new TreeMap<String, Integer>();
080:                for (SVNLogEntry entry : svnLogEntries) {
081:                    if (entry.getAuthor() == null || entry.getDate() == null) {
082:                        // skip invalid log entry
083:                        continue;
084:                    }
085:                    if (createdDate == null) {
086:                        createdDate = entry.getDate();
087:                    }
088:                    commits++;
089:                    long age = now - entry.getDate().getTime();
090:                    String committer = trimName(entry.getAuthor());
091:                    Integer commitsByThisCommitter = commitsPerCommitter
092:                            .get(committer);
093:                    commitsPerCommitter.put(committer,
094:                            (commitsByThisCommitter == null) ? 1
095:                                    : commitsByThisCommitter + 1);
096:                }
097:                return commitsPerCommitter;
098:            }
099:
100:            private static String trimName(String in) {
101:                int pos = in.indexOf('\\');
102:                if (pos != -1) {
103:                    return in.substring(pos + 1).toLowerCase();
104:                }
105:                return in.toLowerCase();
106:            }
107:
108:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.