Source Code Cross Referenced for JavaHLObjectFactory.java in  » Source-Control » tmatesoft-SVN » org » tigris » subversion » javahl » 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 » Source Control » tmatesoft SVN » org.tigris.subversion.javahl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ====================================================================
003:         * Copyright (c) 2004-2008 TMate Software Ltd.  All rights reserved.
004:         *
005:         * This software is licensed as described in the file COPYING, which
006:         * you should have received as part of this distribution.  The terms
007:         * are also available at http://svnkit.com/license.html
008:         * If newer versions of this license are posted there, you may use a
009:         * newer version instead, at your option.
010:         * ====================================================================
011:         */
012:        package org.tigris.subversion.javahl;
013:
014:        import java.io.File;
015:        import java.util.ArrayList;
016:        import java.util.Collection;
017:        import java.util.Date;
018:        import java.util.HashMap;
019:        import java.util.Iterator;
020:        import java.util.Map;
021:
022:        import org.tmatesoft.svn.core.SVNDirEntry;
023:        import org.tmatesoft.svn.core.SVNException;
024:        import org.tmatesoft.svn.core.SVNLock;
025:        import org.tmatesoft.svn.core.SVNLogEntry;
026:        import org.tmatesoft.svn.core.SVNLogEntryPath;
027:        import org.tmatesoft.svn.core.SVNNodeKind;
028:        import org.tmatesoft.svn.core.SVNProperty;
029:        import org.tmatesoft.svn.core.internal.util.SVNPathUtil;
030:        import org.tmatesoft.svn.core.javahl.SVNClientImpl;
031:        import org.tmatesoft.svn.core.wc.SVNCommitItem;
032:        import org.tmatesoft.svn.core.wc.SVNEvent;
033:        import org.tmatesoft.svn.core.wc.SVNEventAction;
034:        import org.tmatesoft.svn.core.wc.SVNInfo;
035:        import org.tmatesoft.svn.core.wc.SVNRevision;
036:        import org.tmatesoft.svn.core.wc.SVNStatus;
037:        import org.tmatesoft.svn.core.wc.SVNStatusType;
038:
039:        /**
040:         * @version 1.1.1
041:         * @author  TMate Software Ltd.
042:         */
043:        public class JavaHLObjectFactory {
044:
045:            private static final Map STATUS_CONVERSION_MAP = new HashMap();
046:            private static final Map REVISION_KIND_CONVERSION_MAP = new HashMap();
047:            private static final Map ACTION_CONVERSION_MAP = new HashMap();
048:            private static final Map LOCK_CONVERSION_MAP = new HashMap();
049:
050:            static {
051:                STATUS_CONVERSION_MAP.put(SVNStatusType.STATUS_ADDED,
052:                        new Integer(StatusKind.added));
053:                STATUS_CONVERSION_MAP.put(SVNStatusType.STATUS_CONFLICTED,
054:                        new Integer(StatusKind.conflicted));
055:                STATUS_CONVERSION_MAP.put(SVNStatusType.STATUS_DELETED,
056:                        new Integer(StatusKind.deleted));
057:                STATUS_CONVERSION_MAP.put(SVNStatusType.STATUS_EXTERNAL,
058:                        new Integer(StatusKind.external));
059:                STATUS_CONVERSION_MAP.put(SVNStatusType.STATUS_IGNORED,
060:                        new Integer(StatusKind.ignored));
061:                STATUS_CONVERSION_MAP.put(SVNStatusType.STATUS_INCOMPLETE,
062:                        new Integer(StatusKind.incomplete));
063:                //STATUS_CONVERSION_MAP.put(SVNStatusType.STATUS_MERGED, new Integer(StatusKind.merged));
064:                STATUS_CONVERSION_MAP.put(SVNStatusType.STATUS_MISSING,
065:                        new Integer(StatusKind.missing));
066:                STATUS_CONVERSION_MAP.put(SVNStatusType.STATUS_MODIFIED,
067:                        new Integer(StatusKind.modified));
068:                STATUS_CONVERSION_MAP.put(SVNStatusType.STATUS_NONE,
069:                        new Integer(StatusKind.none));
070:                STATUS_CONVERSION_MAP.put(SVNStatusType.STATUS_NORMAL,
071:                        new Integer(StatusKind.normal));
072:                STATUS_CONVERSION_MAP.put(SVNStatusType.STATUS_OBSTRUCTED,
073:                        new Integer(StatusKind.obstructed));
074:                STATUS_CONVERSION_MAP.put(SVNStatusType.STATUS_REPLACED,
075:                        new Integer(StatusKind.replaced));
076:                STATUS_CONVERSION_MAP.put(SVNStatusType.STATUS_UNVERSIONED,
077:                        new Integer(StatusKind.unversioned));
078:
079:                STATUS_CONVERSION_MAP.put(SVNStatusType.CHANGED, new Integer(
080:                        NotifyStatus.changed));
081:                STATUS_CONVERSION_MAP.put(SVNStatusType.CONFLICTED,
082:                        new Integer(NotifyStatus.conflicted));
083:                STATUS_CONVERSION_MAP.put(SVNStatusType.INAPPLICABLE,
084:                        new Integer(NotifyStatus.inapplicable));
085:                STATUS_CONVERSION_MAP.put(SVNStatusType.MERGED, new Integer(
086:                        NotifyStatus.merged));
087:                STATUS_CONVERSION_MAP.put(SVNStatusType.MISSING, new Integer(
088:                        NotifyStatus.missing));
089:                STATUS_CONVERSION_MAP.put(SVNStatusType.OBSTRUCTED,
090:                        new Integer(NotifyStatus.obstructed));
091:                STATUS_CONVERSION_MAP.put(SVNStatusType.UNCHANGED, new Integer(
092:                        NotifyStatus.unchanged));
093:                STATUS_CONVERSION_MAP.put(SVNStatusType.UNKNOWN, new Integer(
094:                        NotifyStatus.unknown));
095:
096:                LOCK_CONVERSION_MAP.put(SVNStatusType.LOCK_INAPPLICABLE,
097:                        new Integer(LockStatus.inapplicable));
098:                LOCK_CONVERSION_MAP.put(SVNStatusType.LOCK_LOCKED, new Integer(
099:                        LockStatus.locked));
100:                LOCK_CONVERSION_MAP.put(SVNStatusType.LOCK_UNCHANGED,
101:                        new Integer(LockStatus.unchanged));
102:                LOCK_CONVERSION_MAP.put(SVNStatusType.LOCK_UNKNOWN,
103:                        new Integer(LockStatus.unknown));
104:                LOCK_CONVERSION_MAP.put(SVNStatusType.LOCK_UNLOCKED,
105:                        new Integer(LockStatus.unlocked));
106:
107:                REVISION_KIND_CONVERSION_MAP.put(
108:                        new Integer(RevisionKind.base), SVNRevision.BASE);
109:                REVISION_KIND_CONVERSION_MAP.put(new Integer(
110:                        RevisionKind.committed), SVNRevision.COMMITTED);
111:                REVISION_KIND_CONVERSION_MAP.put(
112:                        new Integer(RevisionKind.head), SVNRevision.HEAD);
113:                REVISION_KIND_CONVERSION_MAP.put(new Integer(
114:                        RevisionKind.previous), SVNRevision.PREVIOUS);
115:                REVISION_KIND_CONVERSION_MAP.put(new Integer(
116:                        RevisionKind.unspecified), SVNRevision.UNDEFINED);
117:                REVISION_KIND_CONVERSION_MAP.put(new Integer(
118:                        RevisionKind.working), SVNRevision.WORKING);
119:
120:                ACTION_CONVERSION_MAP.put(SVNEventAction.ADD, new Integer(
121:                        NotifyAction.add));
122:                ACTION_CONVERSION_MAP.put(SVNEventAction.ANNOTATE, new Integer(
123:                        NotifyAction.blame_revision));
124:                ACTION_CONVERSION_MAP.put(SVNEventAction.COMMIT_ADDED,
125:                        new Integer(NotifyAction.commit_added));
126:                ACTION_CONVERSION_MAP.put(SVNEventAction.COMMIT_DELETED,
127:                        new Integer(NotifyAction.commit_deleted));
128:                ACTION_CONVERSION_MAP.put(SVNEventAction.COMMIT_DELTA_SENT,
129:                        new Integer(NotifyAction.commit_postfix_txdelta));
130:                ACTION_CONVERSION_MAP.put(SVNEventAction.COMMIT_MODIFIED,
131:                        new Integer(NotifyAction.commit_modified));
132:                ACTION_CONVERSION_MAP.put(SVNEventAction.COMMIT_REPLACED,
133:                        new Integer(NotifyAction.commit_replaced));
134:                ACTION_CONVERSION_MAP.put(SVNEventAction.COPY, new Integer(
135:                        NotifyAction.copy));
136:                ACTION_CONVERSION_MAP.put(SVNEventAction.DELETE, new Integer(
137:                        NotifyAction.delete));
138:                ACTION_CONVERSION_MAP.put(SVNEventAction.FAILED_REVERT,
139:                        new Integer(NotifyAction.failed_revert));
140:                ACTION_CONVERSION_MAP.put(SVNEventAction.LOCK_FAILED,
141:                        new Integer(NotifyAction.failed_lock));
142:                ACTION_CONVERSION_MAP.put(SVNEventAction.LOCKED, new Integer(
143:                        NotifyAction.locked));
144:                //ACTION_CONVERSION_MAP.put(SVNEventAction.PROGRESS, new Integer(NotifyAction.));
145:                ACTION_CONVERSION_MAP.put(SVNEventAction.RESOLVED, new Integer(
146:                        NotifyAction.resolved));
147:                ACTION_CONVERSION_MAP.put(SVNEventAction.RESTORE, new Integer(
148:                        NotifyAction.restore));
149:                ACTION_CONVERSION_MAP.put(SVNEventAction.REVERT, new Integer(
150:                        NotifyAction.revert));
151:                ACTION_CONVERSION_MAP.put(SVNEventAction.SKIP, new Integer(
152:                        NotifyAction.skip));
153:                ACTION_CONVERSION_MAP.put(SVNEventAction.STATUS_COMPLETED,
154:                        new Integer(NotifyAction.status_completed));
155:                ACTION_CONVERSION_MAP.put(SVNEventAction.STATUS_EXTERNAL,
156:                        new Integer(NotifyAction.status_external));
157:                ACTION_CONVERSION_MAP.put(SVNEventAction.UNLOCK_FAILED,
158:                        new Integer(NotifyAction.failed_unlock));
159:                ACTION_CONVERSION_MAP.put(SVNEventAction.UNLOCKED, new Integer(
160:                        NotifyAction.unlocked));
161:                ACTION_CONVERSION_MAP.put(SVNEventAction.UPDATE_ADD,
162:                        new Integer(NotifyAction.update_add));
163:                ACTION_CONVERSION_MAP.put(SVNEventAction.UPDATE_COMPLETED,
164:                        new Integer(NotifyAction.update_completed));
165:                ACTION_CONVERSION_MAP.put(SVNEventAction.UPDATE_DELETE,
166:                        new Integer(NotifyAction.update_delete));
167:                ACTION_CONVERSION_MAP.put(SVNEventAction.UPDATE_EXTERNAL,
168:                        new Integer(NotifyAction.update_external));
169:                ACTION_CONVERSION_MAP.put(SVNEventAction.UPDATE_UPDATE,
170:                        new Integer(NotifyAction.update_update));
171:                ACTION_CONVERSION_MAP.put(SVNEventAction.UPDATE_NONE,
172:                        new Integer(NotifyAction.update_update));
173:                // undocumented thing.
174:                ACTION_CONVERSION_MAP.put(SVNEventAction.COMMIT_COMPLETED,
175:                        new Integer(-11));
176:            }
177:
178:            public static Status createStatus(String path, SVNStatus status) {
179:                if (status == null) {
180:                    return null;
181:                }
182:                String url = status.getURL() != null ? status.getURL()
183:                        .toString() : null;
184:                if (url == null && status.getEntryProperties() != null) {
185:                    url = (String) status.getEntryProperties().get(
186:                            SVNProperty.URL);
187:                }
188:                if (url == null && status.getRemoteURL() != null) {
189:                    url = status.getRemoteURL().toString();
190:                }
191:                int nodeKind = getNodeKind(status.getKind());
192:                if (status.getContentsStatus() == SVNStatusType.STATUS_IGNORED) {
193:                    nodeKind = NodeKind.unknown;
194:                }
195:                long revision = status.getRevision().getNumber();
196:                long lastChangedRevision = -1;
197:                if (status.getCommittedRevision() != null) {
198:                    lastChangedRevision = status.getCommittedRevision()
199:                            .getNumber();
200:                }
201:                Date d = status.getCommittedDate();
202:                long lastChangedDate = -1;
203:                if (d != null) {
204:                    lastChangedDate = d.getTime() * 1000;
205:                }
206:                String lastCommitAuthor = status.getAuthor();
207:                int textStatus = getStatusValue(status.getContentsStatus());
208:                int propStatus = getStatusValue(status.getPropertiesStatus());
209:                int repositoryTextStatus = getStatusValue(status
210:                        .getRemoteContentsStatus());
211:                int repositoryPropStatus = getStatusValue(status
212:                        .getRemotePropertiesStatus());
213:                boolean locked = status.isLocked();
214:                boolean copied = status.isCopied();
215:                boolean switched = status.isSwitched();
216:
217:                String conflictOld = "";
218:                if (status.getConflictOldFile() != null) {
219:                    conflictOld = status.getConflictOldFile().getName();
220:                }
221:                String conflictNew = "";
222:                if (status.getConflictNewFile() != null) {
223:                    conflictNew = status.getConflictNewFile().getName();
224:                }
225:                String conflictWorking = "";
226:                if (status.getConflictWrkFile() != null) {
227:                    conflictWorking = status.getConflictWrkFile().getName();
228:                }
229:                String urlCopiedFrom = status.getCopyFromURL();
230:                long revisionCopiedFrom = status.getCopyFromRevision()
231:                        .getNumber();
232:                String lockToken = null;
233:                String lockOwner = null;
234:                String lockComment = null;
235:                long lockCreationDate = 0;
236:                if (status.getLocalLock() != null) {
237:                    lockToken = status.getLocalLock().getID();
238:                    lockOwner = status.getLocalLock().getOwner();
239:                    lockComment = status.getLocalLock().getComment();
240:                    lockCreationDate = status.getLocalLock().getCreationDate()
241:                            .getTime() * 1000;
242:                }
243:                Lock reposLock = createLock(status.getRemoteLock());
244:                if (path != null) {
245:                    path = path.replace(File.separatorChar, '/');
246:                }
247:
248:                long reposRev = status.getRemoteRevision() != null ? status
249:                        .getRemoteRevision().getNumber() : -1;
250:                long reposDate = status.getRemoteDate() != null ? status
251:                        .getRemoteDate().getTime() * 1000 : -1;
252:                String reposAuthor = status.getRemoteAuthor();
253:                int reposKind = getNodeKind(status.getRemoteKind());
254:
255:                Status st = new Status(path, url, nodeKind, revision,
256:                        lastChangedRevision, lastChangedDate, lastCommitAuthor,
257:                        textStatus, propStatus, repositoryTextStatus,
258:                        repositoryPropStatus, locked, copied, conflictOld,
259:                        conflictNew, conflictWorking, urlCopiedFrom,
260:                        revisionCopiedFrom, switched, lockToken, lockOwner,
261:                        lockComment, lockCreationDate, reposLock,
262:                        /* remote: rev, date, kind, author */
263:                        reposRev, reposDate, reposKind, reposAuthor);
264:                return st;
265:            }
266:
267:            public static SVNRevision getSVNRevision(Revision r) {
268:                if (r == null) {
269:                    return SVNRevision.UNDEFINED;
270:                } else if (r.getKind() == RevisionKind.number) {
271:                    return SVNRevision
272:                            .create(((Revision.Number) r).getNumber());
273:                } else if (r.getKind() == RevisionKind.date) {
274:                    return SVNRevision
275:                            .create(((Revision.DateSpec) r).getDate());
276:                } else if (r == Revision.START) {
277:                    return SVNRevision.create(0);
278:                }
279:                return (SVNRevision) REVISION_KIND_CONVERSION_MAP
280:                        .get(new Integer(r.getKind()));
281:            }
282:
283:            public static int getNodeKind(SVNNodeKind svnKind) {
284:                if (svnKind == SVNNodeKind.DIR) {
285:                    return NodeKind.dir;
286:                } else if (svnKind == SVNNodeKind.NONE) {
287:                    return NodeKind.none;
288:                } else if (svnKind == SVNNodeKind.FILE) {
289:                    return NodeKind.file;
290:                }
291:                return NodeKind.unknown;
292:            }
293:
294:            public static int getStatusValue(SVNStatusType svnStatusType) {
295:                Object status = STATUS_CONVERSION_MAP.get(svnStatusType);
296:                if (status == null) {
297:                    return -1;
298:                }
299:                return ((Integer) status).intValue();
300:            }
301:
302:            public static int getLockStatusValue(SVNStatusType svnStatusType) {
303:                Object status = LOCK_CONVERSION_MAP.get(svnStatusType);
304:                if (status == null) {
305:                    return -1;
306:                }
307:                return ((Integer) status).intValue();
308:            }
309:
310:            public static int getNotifyActionValue(SVNEventAction action) {
311:                Object status = ACTION_CONVERSION_MAP.get(action);
312:                if (status == null) {
313:                    return -1;
314:                }
315:                return ((Integer) status).intValue();
316:            }
317:
318:            public static DirEntry createDirEntry(SVNDirEntry dirEntry) {
319:                if (dirEntry == null) {
320:                    return null;
321:                }
322:                return new DirEntry(dirEntry.getRelativePath(),
323:                        getNodeKind(dirEntry.getKind()), dirEntry.getSize(),
324:                        dirEntry.hasProperties(), dirEntry.getRevision(),
325:                        dirEntry.getDate() != null ? dirEntry.getDate()
326:                                .getTime() * 1000 : 0, dirEntry.getAuthor());
327:            }
328:
329:            public static LogMessage createLogMessage(SVNLogEntry logEntry) {
330:                if (logEntry == null) {
331:                    return null;
332:                }
333:                Map cpaths = logEntry.getChangedPaths();
334:                ChangePath[] cp = null;
335:                if (cpaths == null) {
336:                    cp = new ChangePath[] {};
337:                } else {
338:                    Collection clientChangePaths = new ArrayList();
339:                    for (Iterator iter = cpaths.keySet().iterator(); iter
340:                            .hasNext();) {
341:                        String path = (String) iter.next();
342:                        SVNLogEntryPath entryPath = (SVNLogEntryPath) cpaths
343:                                .get(path);
344:                        if (entryPath != null) {
345:                            clientChangePaths
346:                                    .add(new ChangePath(path, entryPath
347:                                            .getCopyRevision(), entryPath
348:                                            .getCopyPath(), entryPath.getType()));
349:                        }
350:                    }
351:                    cp = (ChangePath[]) clientChangePaths
352:                            .toArray(new ChangePath[clientChangePaths.size()]);
353:                }
354:                return new LogMessage(logEntry.getMessage(),
355:                        logEntry.getDate(), logEntry.getRevision(), logEntry
356:                                .getAuthor(), cp);
357:            }
358:
359:            public static CommitItem[] getCommitItems(
360:                    SVNCommitItem[] commitables) {
361:                if (commitables == null) {
362:                    return null;
363:                }
364:                CommitItem[] items = new CommitItem[commitables.length];
365:                for (int i = 0; i < items.length; i++) {
366:                    SVNCommitItem sc = commitables[i];
367:                    if (sc == null) {
368:                        items[i] = null;
369:                    } else {
370:                        int stateFlag = 0;
371:                        if (sc.isDeleted()) {
372:                            stateFlag += CommitItemStateFlags.Delete;
373:                        } else if (sc.isAdded()) {
374:                            stateFlag += CommitItemStateFlags.Add;
375:                        } else if (sc.isContentsModified()) {
376:                            stateFlag += CommitItemStateFlags.TextMods;
377:                        }
378:                        if (sc.isPropertiesModified()) {
379:                            stateFlag += CommitItemStateFlags.PropMods;
380:                        }
381:                        if (sc.isCopied()) {
382:                            stateFlag += CommitItemStateFlags.IsCopy;
383:                        }
384:                        items[i] = new CommitItem(sc.getPath(), getNodeKind(sc
385:                                .getKind()), stateFlag,
386:                                sc.getURL() != null ? sc.getURL().toString()
387:                                        : null,
388:                                sc.getCopyFromURL() != null ? sc
389:                                        .getCopyFromURL().toString() : null, sc
390:                                        .getRevision().getNumber());
391:                    }
392:                }
393:                return items;
394:            }
395:
396:            public static Lock createLock(SVNLock svnLock) {
397:                if (svnLock == null) {
398:                    return null;
399:                }
400:                return new Lock(svnLock.getOwner(), svnLock.getPath(), svnLock
401:                        .getID(), svnLock.getComment(), svnLock
402:                        .getCreationDate() != null ? svnLock.getCreationDate()
403:                        .getTime() * 1000 : 0,
404:                        svnLock.getExpirationDate() != null ? svnLock
405:                                .getExpirationDate().getTime() * 1000 : 0);
406:            }
407:
408:            public static Info createInfo(SVNInfo info) {
409:                if (info == null) {
410:                    return null;
411:                }
412:                int schedule = ScheduleKind.normal;
413:                if (SVNProperty.SCHEDULE_ADD.equals(info.getSchedule())) {
414:                    schedule = ScheduleKind.add;
415:                } else if (SVNProperty.SCHEDULE_DELETE.equals(info
416:                        .getSchedule())) {
417:                    schedule = ScheduleKind.delete;
418:                }
419:                File file = info.getFile();
420:
421:                boolean deleted = file != null && !file.exists()
422:                        && schedule == ScheduleKind.delete;
423:                boolean absent = file != null && !deleted && !file.exists();
424:                boolean incomplete = false;
425:
426:                long copyRev = info.getCopyFromRevision() != null ? info
427:                        .getCopyFromRevision().getNumber() : -1;
428:                String copyUrl = info.getCopyFromURL() != null ? info
429:                        .getCopyFromURL().toString() : null;
430:
431:                String path = info.getFile() != null ? info.getFile().getName()
432:                        : SVNPathUtil.tail(info.getPath());
433:                if (path != null) {
434:                    path = path.replace(File.separatorChar, '/');
435:                }
436:                return new Info(path, info.getURL() != null ? info.getURL()
437:                        .toString() : null, info.getRepositoryUUID(), info
438:                        .getRepositoryRootURL() != null ? info
439:                        .getRepositoryRootURL().toString() : null, schedule,
440:                        getNodeKind(info.getKind()), info.getAuthor(), info
441:                                .getRevision() != null ? info.getRevision()
442:                                .getNumber() : -1,
443:                        info.getCommittedRevision() != null ? info
444:                                .getCommittedRevision().getNumber() : -1, info
445:                                .getCommittedDate(), info.getTextTime(), info
446:                                .getPropTime(),
447:                        info.getCopyFromRevision() != null
448:                                || info.getCopyFromURL() != null, deleted,
449:                        absent, incomplete, copyRev, copyUrl);
450:            }
451:
452:            public static Info2 createInfo2(SVNInfo info) {
453:                if (info == null) {
454:                    return null;
455:                }
456:                int schedule = ScheduleKind.normal;
457:                if (SVNProperty.SCHEDULE_ADD.equals(info.getSchedule())) {
458:                    schedule = ScheduleKind.add;
459:                } else if (SVNProperty.SCHEDULE_DELETE.equals(info
460:                        .getSchedule())) {
461:                    schedule = ScheduleKind.delete;
462:                }
463:                long copyRev = info.getCopyFromRevision() != null ? info
464:                        .getCopyFromRevision().getNumber() : -1;
465:                String copyUrl = info.getCopyFromURL() != null ? info
466:                        .getCopyFromURL().toString() : null;
467:
468:                String path = info.getFile() != null ? info.getFile()
469:                        .getAbsolutePath() : info.getPath();
470:                if (path != null) {
471:                    path = path.replace(File.separatorChar, '/');
472:                }
473:                return new Info2(path, info.getURL() != null ? info.getURL()
474:                        .toString() : null, info.getRevision() != null ? info
475:                        .getRevision().getNumber() : -1, getNodeKind(info
476:                        .getKind()), info.getRepositoryRootURL() != null ? info
477:                        .getRepositoryRootURL().toString() : null, info
478:                        .getRepositoryUUID(),
479:                        info.getCommittedRevision() != null ? info
480:                                .getCommittedRevision().getNumber() : -1, info
481:                                .getCommittedDate() != null ? info
482:                                .getCommittedDate().getTime() * 1000 : 0, info
483:                                .getAuthor(), createLock(info.getLock()), !info
484:                                .isRemote(), schedule, copyUrl, copyRev, info
485:                                .getTextTime() != null ? info.getTextTime()
486:                                .getTime() * 1000 : 0,
487:                        info.getPropTime() != null ? info.getPropTime()
488:                                .getTime() * 1000 : 0, info.getChecksum(), info
489:                                .getConflictOldFile() != null ? info
490:                                .getConflictOldFile().getName() : null, info
491:                                .getConflictNewFile() != null ? info
492:                                .getConflictNewFile().getName() : null, info
493:                                .getConflictWrkFile() != null ? info
494:                                .getConflictWrkFile().getName() : null, info
495:                                .getPropConflictFile() != null ? info
496:                                .getPropConflictFile().getName() : null);
497:            }
498:
499:            public static PropertyData createPropertyData(Object client,
500:                    String path, String name, String value, byte[] data) {
501:                if (client instanceof  SVNClientImpl) {
502:                    return new JavaHLPropertyData((SVNClientImpl) client, null,
503:                            path, name, value, data);
504:                }
505:                return new PropertyData((SVNClient) client, path, name, value,
506:                        data);
507:            }
508:
509:            public static NotifyInformation createNotifyInformation(
510:                    SVNEvent event, String path) {
511:                // include full error message.
512:                String errMsg = null;
513:                if (event.getErrorMessage() != null) {
514:                    errMsg = event.getErrorMessage().getFullMessage();
515:                }
516:                return new NotifyInformation(path, JavaHLObjectFactory
517:                        .getNotifyActionValue(event.getAction()),
518:                        JavaHLObjectFactory.getNodeKind(event.getNodeKind()),
519:                        event.getMimeType(), JavaHLObjectFactory
520:                                .createLock(event.getLock()), errMsg,
521:                        JavaHLObjectFactory.getStatusValue(event
522:                                .getContentsStatus()), JavaHLObjectFactory
523:                                .getStatusValue(event.getPropertiesStatus()),
524:                        JavaHLObjectFactory.getLockStatusValue(event
525:                                .getLockStatus()), event.getRevision());
526:            }
527:
528:            public static void throwException(SVNException e,
529:                    SVNClientImpl svnClient) throws ClientException {
530:                int code = 0;
531:                if (e.getErrorMessage() != null) {
532:                    code = e.getErrorMessage().getErrorCode().getCode();
533:                }
534:                ClientException ec = new ClientException(e.getMessage(), "",
535:                        code);
536:                ec.initCause(e);
537:                svnClient.getClientManager().getDebugLog().info(ec);
538:                svnClient.getClientManager().getDebugLog().info(e);
539:                throw ec;
540:            }
541:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.