Source Code Cross Referenced for SvnChangesetController.java in  » Project-Management » EmForce » ru » emdev » EmForge » svn » web » 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 » Project Management » EmForce » ru.emdev.EmForge.svn.web 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package ru.emdev.EmForge.svn.web;
002:
003:        import java.util.Collection;
004:        import java.util.Date;
005:        import java.util.HashMap;
006:        import java.util.LinkedList;
007:        import java.util.Map;
008:
009:        import org.tmatesoft.svn.core.SVNException;
010:        import org.tmatesoft.svn.core.SVNLogEntry;
011:        import org.tmatesoft.svn.core.SVNLogEntryPath;
012:        import org.tmatesoft.svn.core.SVNNodeKind;
013:        import org.tmatesoft.svn.core.SVNProperty;
014:
015:        import ru.emdev.EmForge.web.bean.MainMenuController.MainMenuItem;
016:        import ru.emdev.EmForge.wiki.web.bean.Crumb;
017:
018:        /**
019:         * Change set backing bean
020:         * 
021:         * @author Walter Mourao
022:         *
023:         */
024:        public class SvnChangesetController extends SvnBaseController {
025:
026:            public static final String PAGE_NAME = "svnchangeset.faces";
027:            public static final String TITLE = "Files changes";
028:
029:            @Override
030:            public MainMenuItem getSelectionItemOnMainMenu() {
031:                return MainMenuItem.SOURCES;
032:            }
033:
034:            @Override
035:            public String getTitleImpl() {
036:                return TITLE;
037:            }
038:
039:            @Override
040:            public Crumb getTrailCrumbInfo() {
041:                return null;
042:            }
043:
044:            @Override
045:            protected void init() {
046:                super .init();
047:
048:                commitMessage = null;
049:
050:                date = null;
051:                age = null;
052:                author = null;
053:                changedFiles = null;
054:                previousRevision = null;
055:                nextRevision = null;
056:                logEntries = null;
057:
058:                loadChanges();
059:            }
060:
061:            //********* controller code ********//
062:
063:            /**
064:             * Fills the relevant properties
065:             */
066:            private void loadChanges() {
067:
068:                final SVNLogEntry logEntry;
069:
070:                if (logEntries == null) {
071:                    try {
072:                        logEntries = Helper.getLogEntries(getSvnRepository(),
073:                                getPath(), 0, -1, true).toArray(
074:                                new SVNLogEntry[0]);
075:                    } catch (SVNException e) {
076:                        this .addErrorMessage("Subversion error", e
077:                                .getLocalizedMessage());
078:                        logger.error(e.getLocalizedMessage());
079:                        changedFiles = new LinkedList<ChangedFile>();
080:                        return;
081:                    }
082:                }
083:
084:                final long baseRevision = Helper
085:                        .getCurrentRevision(getRevision());
086:
087:                // It ia much more chanses - that we will look for latest revisions
088:                // so, better to walk from the end
089:                int entryIndex = logEntries.length - 1;
090:                if (baseRevision > -1) {
091:                    for (int i = logEntries.length - 1; i >= 0; i--) {
092:                        if (logEntries[i].getRevision() == baseRevision) {
093:                            entryIndex = i;
094:                            break;
095:                        }
096:                    }
097:                }
098:
099:                if (entryIndex < logEntries.length - 1) {
100:                    nextRevision = logEntries[entryIndex + 1].getRevision();
101:                }
102:
103:                if (entryIndex > 0) {
104:                    previousRevision = logEntries[entryIndex - 1].getRevision();
105:                }
106:
107:                logEntry = logEntries[entryIndex];
108:
109:                final Map<String, SVNLogEntryPath> changedPaths = logEntry
110:                        .getChangedPaths();
111:
112:                changedFiles = new LinkedList<ChangedFile>();
113:
114:                // iterate changed paths.
115:                // if some path will be failed - just skip it
116:                for (SVNLogEntryPath logPath : changedPaths.values()) {
117:                    final SVNNodeKind kind;
118:                    try {
119:                        kind = getSvnRepository().checkPath(logPath.getPath(),
120:                                logEntry.getRevision());
121:                    } catch (SVNException e) {
122:                        this .addErrorMessage("Subversion error", e
123:                                .getLocalizedMessage());
124:                        logger.error(e.getLocalizedMessage(), e);
125:                        continue;
126:                    }
127:
128:                    //avoid directory entries. is it needed ?
129:                    if (kind.equals(SVNNodeKind.FILE)) {
130:                        final Map fileProperties = new HashMap();
131:                        try {
132:                            getSvnRepository().getFile(logPath.getPath(),
133:                                    logEntry.getRevision(), fileProperties,
134:                                    null);
135:
136:                            String mimeType = (String) fileProperties
137:                                    .get(SVNProperty.MIME_TYPE);
138:
139:                            /* I will skip it for now
140:                            final boolean fileTextType = SVNProperty.isTextMimeType( mimeType );
141:                            
142:                            final ByteArrayOutputStream baos = new ByteArrayOutputStream( );
143:                            
144:                            if (fileTextType) {
145:                            	getSvnRepository().getFile( getPath() , logEntry.getRevision() , null , baos );
146:                            }
147:                             */
148:
149:                            changedFiles.add(new ChangedFile(logPath.getPath()
150:                                    .substring(1), logPath.getType(), null,
151:                                    false, mimeType));
152:
153:                        } catch (SVNException e) {
154:                            // [AKA] Whole log was full of the messages from here.
155:                            // So, I disabled messaging here
156:                            logger.error(e.getLocalizedMessage());
157:                            continue;
158:                        }
159:                    } else {
160:                        changedFiles.add(new ChangedFile(logPath.getPath()
161:                                .substring(1), logPath.getType(), null, false,
162:                                "directory"));
163:                    }
164:                }
165:
166:                age = Helper.formatAge(logEntry.getDate());
167:                author = logEntry.getAuthor();
168:                date = logEntry.getDate();
169:                commitMessage = logEntry.getMessage();
170:                setRevision(logEntry.getRevision());
171:            }
172:
173:            //********* attributes ***********//
174:
175:            /**
176:             * The subversion log entries
177:             */
178:            private SVNLogEntry[] logEntries;
179:
180:            public SVNLogEntry[] getLogEntries() {
181:                return logEntries;
182:            }
183:
184:            //the setter is needed only if using t:saveState
185:            public void setLogEntries(SVNLogEntry[] logEntries) {
186:                this .logEntries = logEntries;
187:            }
188:
189:            /**
190:             * The log commit message
191:             */
192:            private String commitMessage;
193:
194:            public String getCommitMessage() {
195:                return commitMessage;
196:            }
197:
198:            /**
199:             * The date of the change set
200:             */
201:            private Date date;
202:
203:            public Date getDate() {
204:                return date;
205:            }
206:
207:            /**
208:             * The date of the change set in the form "xx months ago"
209:             */
210:            private String age;
211:
212:            public String getAge() {
213:                return age;
214:            }
215:
216:            /**
217:             *  The author of the revision
218:             */
219:            private String author;
220:
221:            public String getAuthor() {
222:                return author;
223:            }
224:
225:            /**
226:             * The changed files information
227:             */
228:            private Collection<ChangedFile> changedFiles;
229:
230:            public Collection<ChangedFile> getChangedFiles() {
231:                return changedFiles;
232:            }
233:
234:            /**
235:             * The next revision number, null if the current is the last.
236:             */
237:            private Long nextRevision;
238:
239:            public Long getNextRevision() {
240:                return nextRevision;
241:            }
242:
243:            /**
244:             * The previous revision number, null if the current is the first.
245:             */
246:            private Long previousRevision;
247:
248:            public Long getPreviousRevision() {
249:                return previousRevision;
250:            }
251:
252:            /**
253:             * The user properties of the current change set
254:             */
255:            private Collection<String[]> resourceProperties;
256:
257:            public Collection<String[]> getResourceProperties() {
258:                return resourceProperties;
259:            }
260:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.