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


0001:        /*
0002:         * ====================================================================
0003:         * Copyright (c) 2004-2008 TMate Software Ltd.  All rights reserved.
0004:         *
0005:         * This software is licensed as described in the file COPYING, which
0006:         * you should have received as part of this distribution.  The terms
0007:         * are also available at http://svnkit.com/license.html
0008:         * If newer versions of this license are posted there, you may use a
0009:         * newer version instead, at your option.
0010:         * ====================================================================
0011:         */
0012:        package org.tmatesoft.svn.core.javahl;
0013:
0014:        import java.io.ByteArrayOutputStream;
0015:        import java.io.File;
0016:        import java.io.IOException;
0017:        import java.io.OutputStream;
0018:        import java.util.ArrayList;
0019:        import java.util.Collection;
0020:        import java.util.Date;
0021:        import java.util.List;
0022:
0023:        import org.tigris.subversion.javahl.BlameCallback;
0024:        import org.tigris.subversion.javahl.ClientException;
0025:        import org.tigris.subversion.javahl.CommitItem;
0026:        import org.tigris.subversion.javahl.CommitMessage;
0027:        import org.tigris.subversion.javahl.DirEntry;
0028:        import org.tigris.subversion.javahl.Info;
0029:        import org.tigris.subversion.javahl.Info2;
0030:        import org.tigris.subversion.javahl.JavaHLObjectFactory;
0031:        import org.tigris.subversion.javahl.LogMessage;
0032:        import org.tigris.subversion.javahl.Notify;
0033:        import org.tigris.subversion.javahl.Notify2;
0034:        import org.tigris.subversion.javahl.NotifyInformation;
0035:        import org.tigris.subversion.javahl.PromptUserPassword;
0036:        import org.tigris.subversion.javahl.PropertyData;
0037:        import org.tigris.subversion.javahl.Revision;
0038:        import org.tigris.subversion.javahl.SVNClient;
0039:        import org.tigris.subversion.javahl.SVNClientInterface;
0040:        import org.tigris.subversion.javahl.SVNClientLogLevel;
0041:        import org.tigris.subversion.javahl.Status;
0042:        import org.tmatesoft.svn.core.ISVNDirEntryHandler;
0043:        import org.tmatesoft.svn.core.ISVNLogEntryHandler;
0044:        import org.tmatesoft.svn.core.SVNCancelException;
0045:        import org.tmatesoft.svn.core.SVNCommitInfo;
0046:        import org.tmatesoft.svn.core.SVNDirEntry;
0047:        import org.tmatesoft.svn.core.SVNErrorCode;
0048:        import org.tmatesoft.svn.core.SVNException;
0049:        import org.tmatesoft.svn.core.SVNLogEntry;
0050:        import org.tmatesoft.svn.core.SVNNodeKind;
0051:        import org.tmatesoft.svn.core.SVNURL;
0052:        import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
0053:        import org.tmatesoft.svn.core.auth.ISVNAuthenticationStorage;
0054:        import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
0055:        import org.tmatesoft.svn.core.internal.io.dav.http.IHTTPConnectionFactory;
0056:        import org.tmatesoft.svn.core.internal.io.fs.FSRepositoryFactory;
0057:        import org.tmatesoft.svn.core.internal.io.svn.ISVNConnectorFactory;
0058:        import org.tmatesoft.svn.core.internal.io.svn.SVNSSHSession;
0059:        import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl;
0060:        import org.tmatesoft.svn.core.internal.util.SVNFormatUtil;
0061:        import org.tmatesoft.svn.core.internal.wc.SVNErrorManager;
0062:        import org.tmatesoft.svn.core.internal.wc.SVNFileType;
0063:        import org.tmatesoft.svn.core.internal.wc.SVNFileUtil;
0064:        import org.tmatesoft.svn.core.wc.DefaultSVNRepositoryPool;
0065:        import org.tmatesoft.svn.core.wc.ISVNAnnotateHandler;
0066:        import org.tmatesoft.svn.core.wc.ISVNCommitHandler;
0067:        import org.tmatesoft.svn.core.wc.ISVNEventHandler;
0068:        import org.tmatesoft.svn.core.wc.ISVNInfoHandler;
0069:        import org.tmatesoft.svn.core.wc.ISVNOptions;
0070:        import org.tmatesoft.svn.core.wc.ISVNPropertyHandler;
0071:        import org.tmatesoft.svn.core.wc.ISVNStatusHandler;
0072:        import org.tmatesoft.svn.core.wc.SVNClientManager;
0073:        import org.tmatesoft.svn.core.wc.SVNCommitClient;
0074:        import org.tmatesoft.svn.core.wc.SVNCommitItem;
0075:        import org.tmatesoft.svn.core.wc.SVNCommitPacket;
0076:        import org.tmatesoft.svn.core.wc.SVNCopyClient;
0077:        import org.tmatesoft.svn.core.wc.SVNDiffClient;
0078:        import org.tmatesoft.svn.core.wc.SVNEvent;
0079:        import org.tmatesoft.svn.core.wc.SVNInfo;
0080:        import org.tmatesoft.svn.core.wc.SVNLogClient;
0081:        import org.tmatesoft.svn.core.wc.SVNRevision;
0082:        import org.tmatesoft.svn.core.wc.SVNStatus;
0083:        import org.tmatesoft.svn.core.wc.SVNStatusClient;
0084:        import org.tmatesoft.svn.core.wc.SVNStatusType;
0085:        import org.tmatesoft.svn.core.wc.SVNUpdateClient;
0086:        import org.tmatesoft.svn.core.wc.SVNWCClient;
0087:        import org.tmatesoft.svn.core.wc.SVNWCUtil;
0088:        import org.tmatesoft.svn.util.Version;
0089:
0090:        /**
0091:         * @version 1.1.1
0092:         * @author  TMate Software Ltd.
0093:         */
0094:        public class SVNClientImpl implements  SVNClientInterface {
0095:
0096:            private static int ourInstanceCount;
0097:
0098:            private String myConfigDir;
0099:            private PromptUserPassword myPrompt;
0100:            private String myUserName;
0101:            private String myPassword;
0102:            private ISVNEventHandler mySVNEventListener;
0103:            /**
0104:             * @deprecated
0105:             */
0106:            private Notify myNotify;
0107:            private Notify2 myNotify2;
0108:            private CommitMessage myMessageHandler;
0109:            private ISVNOptions myOptions;
0110:            private boolean myCancelOperation = false;
0111:            private SVNClientManager myClientManager;
0112:            private SVNClientInterface myOwner;
0113:
0114:            private ISVNAuthenticationManager myAuthenticationManager;
0115:
0116:            private ISVNAuthenticationStorage myAuthStorage;
0117:            private static ISVNAuthenticationStorage ourAuthStorage;
0118:
0119:            /**
0120:             * @version 1.1.1
0121:             * @author  TMate Software Ltd.
0122:             */
0123:            public static final class LogLevel implements  SVNClientLogLevel {
0124:
0125:            }
0126:
0127:            public static SVNClientImpl newInstance() {
0128:                return newInstance(null);
0129:            }
0130:
0131:            public static SVNClientImpl newInstance(SVNClient owner) {
0132:                return newInstance(owner, null, null);
0133:            }
0134:
0135:            public static SVNClientImpl newInstance(SVNClient owner,
0136:                    IHTTPConnectionFactory httpConnectionFactory,
0137:                    ISVNConnectorFactory svnConnectorFactory) {
0138:                return newInstance(owner, httpConnectionFactory,
0139:                        svnConnectorFactory, true);
0140:            }
0141:
0142:            public static SVNClientImpl newInstance(SVNClient owner,
0143:                    IHTTPConnectionFactory httpConnectionFactory,
0144:                    ISVNConnectorFactory svnConnectorFactory,
0145:                    boolean trackClient) {
0146:                SVNClientImpl client = new SVNClientImpl(owner,
0147:                        httpConnectionFactory, svnConnectorFactory);
0148:                if (trackClient) {
0149:                    SVNClientImplTracker.registerClient(client);
0150:                }
0151:                return client;
0152:            }
0153:
0154:            public static ISVNAuthenticationStorage getRuntimeCredentialsStorage() {
0155:                synchronized (SVNClientImpl.class) {
0156:                    if (ourAuthStorage == null) {
0157:                        ourAuthStorage = new JavaHLAuthenticationStorage();
0158:                    }
0159:                    return ourAuthStorage;
0160:                }
0161:            }
0162:
0163:            public static void setRuntimeCredentialsStorage(
0164:                    ISVNAuthenticationStorage storage) {
0165:                synchronized (SVNClientImpl.class) {
0166:                    ourAuthStorage = storage == null ? new JavaHLAuthenticationStorage()
0167:                            : storage;
0168:                }
0169:            }
0170:
0171:            public ISVNAuthenticationStorage getClientCredentialsStorage() {
0172:                if (myAuthStorage != null) {
0173:                    return myAuthStorage;
0174:                }
0175:                return getRuntimeCredentialsStorage();
0176:            }
0177:
0178:            public void setClientCredentialsStorage(
0179:                    ISVNAuthenticationStorage storage) {
0180:                myAuthStorage = storage;
0181:                updateClientManager();
0182:            }
0183:
0184:            protected SVNClientImpl(SVNClient owner) {
0185:                this (owner, null, null);
0186:            }
0187:
0188:            protected SVNClientImpl(SVNClient owner,
0189:                    IHTTPConnectionFactory httpConnectionFactory,
0190:                    ISVNConnectorFactory svnConnectorFactory) {
0191:                DAVRepositoryFactory.setup(httpConnectionFactory);
0192:                SVNRepositoryFactoryImpl.setup(svnConnectorFactory);
0193:                FSRepositoryFactory.setup();
0194:                myConfigDir = SVNWCUtil.getDefaultConfigurationDirectory()
0195:                        .getAbsolutePath();
0196:                myOwner = owner == null ? (SVNClientInterface) this 
0197:                        : (SVNClientInterface) owner;
0198:                synchronized (SVNClientImpl.class) {
0199:                    ourInstanceCount++;
0200:                }
0201:            }
0202:
0203:            public String getLastPath() {
0204:                return null;
0205:            }
0206:
0207:            public Status[] status(String path, boolean descend,
0208:                    boolean onServer, boolean getAll) throws ClientException {
0209:                return status(path, descend, onServer, getAll, false);
0210:            }
0211:
0212:            public Status[] status(String path, boolean descend,
0213:                    boolean onServer, boolean getAll, boolean noIgnore)
0214:                    throws ClientException {
0215:                return status(path, descend, onServer, getAll, noIgnore, false);
0216:            }
0217:
0218:            public Status[] status(final String path, boolean descend,
0219:                    boolean onServer, boolean getAll, boolean noIgnore,
0220:                    boolean ignoreExternals) throws ClientException {
0221:                if (path == null) {
0222:                    return null;
0223:                }
0224:                final Collection statuses = new ArrayList();
0225:                SVNStatusClient stClient = getSVNStatusClient();
0226:                boolean oldIgnoreExternals = stClient.isIgnoreExternals();
0227:                stClient.setIgnoreExternals(ignoreExternals);
0228:                try {
0229:                    stClient.doStatus(new File(path).getAbsoluteFile(),
0230:                            descend, onServer, getAll, noIgnore,
0231:                            !ignoreExternals, new ISVNStatusHandler() {
0232:                                public void handleStatus(SVNStatus status) {
0233:                                    statuses.add(JavaHLObjectFactory
0234:                                            .createStatus(status.getFile()
0235:                                                    .getPath(), status));
0236:                                }
0237:                            });
0238:                } catch (SVNException e) {
0239:                    throwException(e);
0240:                } finally {
0241:                    stClient.setIgnoreExternals(oldIgnoreExternals);
0242:                }
0243:                return (Status[]) statuses.toArray(new Status[statuses.size()]);
0244:            }
0245:
0246:            public DirEntry[] list(String url, Revision revision,
0247:                    boolean recurse) throws ClientException {
0248:                return list(url, revision, null, recurse);
0249:            }
0250:
0251:            public DirEntry[] list(String url, Revision revision,
0252:                    Revision pegRevision, boolean recurse)
0253:                    throws ClientException {
0254:                final Collection allEntries = new ArrayList();
0255:                SVNLogClient client = getSVNLogClient();
0256:                ISVNDirEntryHandler handler = new ISVNDirEntryHandler() {
0257:                    public void handleDirEntry(SVNDirEntry dirEntry) {
0258:                        allEntries.add(JavaHLObjectFactory
0259:                                .createDirEntry(dirEntry));
0260:                    }
0261:                };
0262:                try {
0263:                    if (isURL(url)) {
0264:                        client
0265:                                .doList(SVNURL.parseURIEncoded(url),
0266:                                        JavaHLObjectFactory
0267:                                                .getSVNRevision(pegRevision),
0268:                                        JavaHLObjectFactory
0269:                                                .getSVNRevision(revision),
0270:                                        recurse, handler);
0271:                    } else {
0272:                        client
0273:                                .doList(new File(url).getAbsoluteFile(),
0274:                                        JavaHLObjectFactory
0275:                                                .getSVNRevision(pegRevision),
0276:                                        JavaHLObjectFactory
0277:                                                .getSVNRevision(revision),
0278:                                        recurse, handler);
0279:                    }
0280:                } catch (SVNException e) {
0281:                    throwException(e);
0282:                }
0283:                return (DirEntry[]) allEntries.toArray(new DirEntry[allEntries
0284:                        .size()]);
0285:            }
0286:
0287:            public Status singleStatus(final String path, boolean onServer)
0288:                    throws ClientException {
0289:                if (path == null) {
0290:                    return null;
0291:                }
0292:                SVNStatusClient client = getSVNStatusClient();
0293:                SVNStatus status = null;
0294:                try {
0295:                    status = client.doStatus(new File(path).getAbsoluteFile(),
0296:                            onServer);
0297:                } catch (SVNException e) {
0298:                    if (e.getErrorMessage().getErrorCode() == SVNErrorCode.WC_NOT_DIRECTORY) {
0299:                        File file = new File(path).getAbsoluteFile();
0300:                        SVNFileType ft = SVNFileType.getType(file);
0301:                        status = new SVNStatus(null, file,
0302:                                ft == SVNFileType.NONE ? SVNNodeKind.NONE
0303:                                        : SVNNodeKind.UNKNOWN, null, null,
0304:                                null, null, SVNStatusType.STATUS_UNVERSIONED,
0305:                                SVNStatusType.STATUS_NONE,
0306:                                SVNStatusType.STATUS_NONE,
0307:                                SVNStatusType.STATUS_NONE, false, false, false,
0308:                                null, null, null, null, null, null, null, null,
0309:                                null);
0310:                    } else {
0311:                        throwException(e);
0312:                    }
0313:                }
0314:                return JavaHLObjectFactory.createStatus(path, status);
0315:            }
0316:
0317:            public void username(String username) {
0318:                myUserName = username;
0319:                updateClientManager();
0320:            }
0321:
0322:            public void password(String password) {
0323:                myPassword = password;
0324:                updateClientManager();
0325:            }
0326:
0327:            public void setPrompt(PromptUserPassword prompt) {
0328:                myPrompt = prompt;
0329:                updateClientManager();
0330:            }
0331:
0332:            private void updateClientManager() {
0333:                File configDir = myConfigDir == null ? null : new File(
0334:                        myConfigDir);
0335:                myOptions = SVNWCUtil.createDefaultOptions(configDir, true);
0336:                myAuthenticationManager = SVNWCUtil
0337:                        .createDefaultAuthenticationManager(configDir,
0338:                                myUserName, myPassword, myOptions
0339:                                        .isAuthStorageEnabled());
0340:                if (myPrompt != null) {
0341:                    myAuthenticationManager
0342:                            .setAuthenticationProvider(new JavaHLAuthenticationProvider(
0343:                                    myPrompt));
0344:                } else {
0345:                    myAuthenticationManager.setAuthenticationProvider(null);
0346:                }
0347:                myAuthenticationManager
0348:                        .setRuntimeStorage(getClientCredentialsStorage());
0349:                if (myClientManager != null) {
0350:                    myClientManager.shutdownConnections(true);
0351:                    myClientManager
0352:                            .setAuthenticationManager(myAuthenticationManager);
0353:                    myClientManager.setOptions(myOptions);
0354:                }
0355:            }
0356:
0357:            public LogMessage[] logMessages(String path,
0358:                    Revision revisionStart, Revision revisionEnd)
0359:                    throws ClientException {
0360:                return logMessages(path, revisionStart, revisionEnd, true,
0361:                        false, 0);
0362:            }
0363:
0364:            public LogMessage[] logMessages(String path,
0365:                    Revision revisionStart, Revision revisionEnd,
0366:                    boolean stopOnCopy) throws ClientException {
0367:                return logMessages(path, revisionStart, revisionEnd,
0368:                        stopOnCopy, false, 0);
0369:            }
0370:
0371:            public LogMessage[] logMessages(String path,
0372:                    Revision revisionStart, Revision revisionEnd,
0373:                    boolean stopOnCopy, boolean discoverPath)
0374:                    throws ClientException {
0375:                return logMessages(path, revisionStart, revisionEnd,
0376:                        stopOnCopy, discoverPath, 0);
0377:            }
0378:
0379:            public LogMessage[] logMessages(String path,
0380:                    Revision revisionStart, Revision revisionEnd,
0381:                    boolean stopOnCopy, boolean discoverPath, long limit)
0382:                    throws ClientException {
0383:                SVNLogClient client = getSVNLogClient();
0384:                final Collection entries = new ArrayList();
0385:                try {
0386:                    if (isURL(path)) {
0387:                        client
0388:                                .doLog(SVNURL.parseURIEncoded(path),
0389:                                        new String[] { "" }, SVNRevision.HEAD,
0390:                                        JavaHLObjectFactory
0391:                                                .getSVNRevision(revisionStart),
0392:                                        JavaHLObjectFactory
0393:                                                .getSVNRevision(revisionEnd),
0394:                                        stopOnCopy, discoverPath, limit,
0395:                                        new ISVNLogEntryHandler() {
0396:                                            public void handleLogEntry(
0397:                                                    SVNLogEntry logEntry) {
0398:                                                entries
0399:                                                        .add(JavaHLObjectFactory
0400:                                                                .createLogMessage(logEntry));
0401:                                            }
0402:                                        });
0403:                    } else {
0404:                        client
0405:                                .doLog(new File[] { new File(path)
0406:                                        .getAbsoluteFile() },
0407:                                        JavaHLObjectFactory
0408:                                                .getSVNRevision(revisionStart),
0409:                                        JavaHLObjectFactory
0410:                                                .getSVNRevision(revisionEnd),
0411:                                        stopOnCopy, discoverPath, limit,
0412:                                        new ISVNLogEntryHandler() {
0413:                                            public void handleLogEntry(
0414:                                                    SVNLogEntry logEntry) {
0415:                                                entries
0416:                                                        .add(JavaHLObjectFactory
0417:                                                                .createLogMessage(logEntry));
0418:                                            }
0419:                                        });
0420:                    }
0421:                } catch (SVNException e) {
0422:                    throwException(e);
0423:                }
0424:                return (LogMessage[]) entries.toArray(new LogMessage[entries
0425:                        .size()]);
0426:            }
0427:
0428:            public long checkout(String moduleName, String destPath,
0429:                    Revision revision, Revision pegRevision, boolean recurse,
0430:                    boolean ignoreExternals) throws ClientException {
0431:                SVNUpdateClient updater = getSVNUpdateClient();
0432:                boolean oldIgnoreExternals = updater.isIgnoreExternals();
0433:                updater.setIgnoreExternals(ignoreExternals);
0434:                try {
0435:                    File path = new File(destPath).getAbsoluteFile();
0436:                    return updater.doCheckout(SVNURL
0437:                            .parseURIEncoded(moduleName), path,
0438:                            JavaHLObjectFactory.getSVNRevision(pegRevision),
0439:                            JavaHLObjectFactory.getSVNRevision(revision),
0440:                            recurse);
0441:                } catch (SVNException e) {
0442:                    throwException(e);
0443:                } finally {
0444:                    updater.setIgnoreExternals(oldIgnoreExternals);
0445:                }
0446:                return -1;
0447:            }
0448:
0449:            public long checkout(String moduleName, String destPath,
0450:                    Revision revision, boolean recurse) throws ClientException {
0451:                return checkout(moduleName, destPath, revision, null, recurse,
0452:                        false);
0453:            }
0454:
0455:            /**
0456:             * @deprecated
0457:             */
0458:            public void notification(Notify notify) {
0459:                myNotify = notify;
0460:            }
0461:
0462:            public void notification2(Notify2 notify) {
0463:                myNotify2 = notify;
0464:            }
0465:
0466:            public void commitMessageHandler(CommitMessage messageHandler) {
0467:                myMessageHandler = messageHandler;
0468:            }
0469:
0470:            public void remove(String[] path, String message, boolean force)
0471:                    throws ClientException {
0472:                boolean areURLs = false;
0473:                for (int i = 0; i < path.length; i++) {
0474:                    areURLs = areURLs || isURL(path[i]);
0475:                }
0476:                if (areURLs) {
0477:                    SVNCommitClient client = getSVNCommitClient();
0478:                    SVNURL[] urls = new SVNURL[path.length];
0479:                    for (int i = 0; i < urls.length; i++) {
0480:                        try {
0481:                            urls[i] = SVNURL.parseURIEncoded(path[i]);
0482:                        } catch (SVNException e) {
0483:                            throwException(e);
0484:                        }
0485:                    }
0486:                    try {
0487:                        client.doDelete(urls, message);
0488:                    } catch (SVNException e) {
0489:                        throwException(e);
0490:                    }
0491:                } else {
0492:                    SVNWCClient client = getSVNWCClient();
0493:                    for (int i = 0; i < path.length; i++) {
0494:                        try {
0495:                            client.doDelete(
0496:                                    new File(path[i]).getAbsoluteFile(), force,
0497:                                    false);
0498:                        } catch (SVNException e) {
0499:                            throwException(e);
0500:                        }
0501:                    }
0502:                }
0503:            }
0504:
0505:            public void revert(String path, boolean recurse)
0506:                    throws ClientException {
0507:                SVNWCClient client = getSVNWCClient();
0508:                try {
0509:                    client.doRevert(new File(path).getAbsoluteFile(), recurse);
0510:                } catch (SVNException e) {
0511:                    throwException(e);
0512:                }
0513:            }
0514:
0515:            public void add(String path, boolean recurse)
0516:                    throws ClientException {
0517:                add(path, recurse, false);
0518:            }
0519:
0520:            public void add(String path, boolean recurse, boolean force)
0521:                    throws ClientException {
0522:                SVNWCClient wcClient = getSVNWCClient();
0523:                try {
0524:                    wcClient.doAdd(new File(path).getAbsoluteFile(), force,
0525:                            false, false, recurse, false);
0526:                } catch (SVNException e) {
0527:                    throwException(e);
0528:                }
0529:            }
0530:
0531:            public long update(String path, Revision revision, boolean recurse)
0532:                    throws ClientException {
0533:                SVNUpdateClient client = getSVNUpdateClient();
0534:                try {
0535:                    return client.doUpdate(new File(path).getAbsoluteFile(),
0536:                            JavaHLObjectFactory.getSVNRevision(revision),
0537:                            recurse);
0538:                } catch (SVNException e) {
0539:                    throwException(e);
0540:                }
0541:                return -1;
0542:            }
0543:
0544:            public long[] update(String[] path, Revision revision,
0545:                    boolean recurse, boolean ignoreExternals)
0546:                    throws ClientException {
0547:                if (path == null || path.length == 0) {
0548:                    return new long[] {};
0549:                }
0550:                long[] updated = new long[path.length];
0551:                SVNUpdateClient updater = getSVNUpdateClient();
0552:                boolean oldIgnore = updater.isIgnoreExternals();
0553:                updater.setIgnoreExternals(ignoreExternals);
0554:                updater.setEventPathPrefix("");
0555:                try {
0556:                    for (int i = 0; i < updated.length; i++) {
0557:                        updated[i] = update(path[i], revision, recurse);
0558:                    }
0559:                } finally {
0560:                    updater.setIgnoreExternals(oldIgnore);
0561:                    updater.setEventPathPrefix(null);
0562:                    SVNFileUtil.sleepForTimestamp();
0563:                }
0564:                return updated;
0565:            }
0566:
0567:            public long commit(String[] path, String message, boolean recurse)
0568:                    throws ClientException {
0569:                return commit(path, message, recurse, false);
0570:            }
0571:
0572:            public long commit(String[] path, String message, boolean recurse,
0573:                    boolean noUnlock) throws ClientException {
0574:                if (path == null || path.length == 0) {
0575:                    return 0;
0576:                }
0577:                SVNCommitClient client = getSVNCommitClient();
0578:                File[] files = new File[path.length];
0579:                for (int i = 0; i < path.length; i++) {
0580:                    files[i] = new File(path[i]).getAbsoluteFile();
0581:                }
0582:                try {
0583:                    if (myMessageHandler != null) {
0584:                        client.setCommitHandler(new ISVNCommitHandler() {
0585:                            public String getCommitMessage(String cmessage,
0586:                                    SVNCommitItem[] commitables) {
0587:                                CommitItem[] items = JavaHLObjectFactory
0588:                                        .getCommitItems(commitables);
0589:                                return myMessageHandler.getLogMessage(items);
0590:                            }
0591:                        });
0592:                    }
0593:                    return client.doCommit(files, noUnlock, message, !recurse,
0594:                            recurse).getNewRevision();
0595:                } catch (SVNException e) {
0596:                    throwException(e);
0597:                }
0598:                return -1;
0599:            }
0600:
0601:            public long[] commit(String[] path, String message,
0602:                    boolean recurse, boolean noUnlock, boolean atomicCommit)
0603:                    throws ClientException {
0604:                if (path == null || path.length == 0) {
0605:                    return new long[0];
0606:                }
0607:                SVNCommitClient client = getSVNCommitClient();
0608:                File[] files = new File[path.length];
0609:                for (int i = 0; i < path.length; i++) {
0610:                    files[i] = new File(path[i]).getAbsoluteFile();
0611:                }
0612:                SVNCommitPacket[] packets = null;
0613:                SVNCommitInfo[] commitResults = null;
0614:                try {
0615:                    if (myMessageHandler != null) {
0616:                        client.setCommitHandler(new ISVNCommitHandler() {
0617:                            public String getCommitMessage(String cmessage,
0618:                                    SVNCommitItem[] commitables) {
0619:                                CommitItem[] items = JavaHLObjectFactory
0620:                                        .getCommitItems(commitables);
0621:                                return myMessageHandler.getLogMessage(items);
0622:                            }
0623:                        });
0624:                    }
0625:                    packets = client.doCollectCommitItems(files, noUnlock,
0626:                            !recurse, recurse, atomicCommit);
0627:                    commitResults = client.doCommit(packets, noUnlock, message);
0628:                } catch (SVNException e) {
0629:                    throwException(e);
0630:                }
0631:                if (commitResults != null && commitResults.length > 0) {
0632:                    long[] revisions = new long[commitResults.length];
0633:                    for (int i = 0; i < commitResults.length; i++) {
0634:                        SVNCommitInfo result = commitResults[i];
0635:                        revisions[i] = result.getNewRevision();
0636:                    }
0637:                    return revisions;
0638:
0639:                }
0640:                return new long[0];
0641:            }
0642:
0643:            public void copy(String srcPath, String destPath, String message,
0644:                    Revision revision) throws ClientException {
0645:                SVNCopyClient client = getSVNCopyClient();
0646:                SVNRevision srcRevision = JavaHLObjectFactory
0647:                        .getSVNRevision(revision);
0648:                try {
0649:                    if (isURL(srcPath) && isURL(destPath)) {
0650:                        client.doCopy(SVNURL.parseURIEncoded(srcPath),
0651:                                srcRevision, SVNURL.parseURIEncoded(destPath),
0652:                                false, message);
0653:                    } else if (isURL(srcPath) && !isURL(destPath)) {
0654:                        client.doCopy(SVNURL.parseURIEncoded(srcPath),
0655:                                srcRevision, new File(destPath)
0656:                                        .getAbsoluteFile());
0657:                    } else if (!isURL(srcPath) && isURL(destPath)) {
0658:                        client.doCopy(new File(srcPath).getAbsoluteFile(),
0659:                                srcRevision, SVNURL.parseURIEncoded(destPath),
0660:                                message);
0661:                    } else if (!isURL(srcPath) && !isURL(destPath)) {
0662:                        client.doCopy(new File(srcPath).getAbsoluteFile(),
0663:                                srcRevision, new File(destPath)
0664:                                        .getAbsoluteFile(), false, false);
0665:                    }
0666:                } catch (SVNException e) {
0667:                    throwException(e);
0668:                }
0669:            }
0670:
0671:            public void move(String srcPath, String destPath, String message,
0672:                    Revision revision, boolean force) throws ClientException {
0673:                SVNCopyClient client = getSVNCopyClient();
0674:                SVNRevision srcRevision = JavaHLObjectFactory
0675:                        .getSVNRevision(revision);
0676:                try {
0677:                    if (isURL(srcPath) && isURL(destPath)) {
0678:                        client.doCopy(SVNURL.parseURIEncoded(srcPath),
0679:                                srcRevision, SVNURL.parseURIEncoded(destPath),
0680:                                true, message);
0681:                    } else if (!isURL(srcPath) && !isURL(destPath)) {
0682:                        client.doCopy(new File(srcPath).getAbsoluteFile(),
0683:                                srcRevision, new File(destPath)
0684:                                        .getAbsoluteFile(), force, true);
0685:                    }
0686:                } catch (SVNException e) {
0687:                    throwException(e);
0688:                }
0689:            }
0690:
0691:            public void move(String srcPath, String destPath, String message,
0692:                    boolean force) throws ClientException {
0693:                move(srcPath, destPath, message, Revision.WORKING, force);
0694:            }
0695:
0696:            public void mkdir(String[] path, String message)
0697:                    throws ClientException {
0698:                SVNCommitClient client = getSVNCommitClient();
0699:                List urls = new ArrayList();
0700:                List paths = new ArrayList();
0701:                for (int i = 0; i < path.length; i++) {
0702:                    if (isURL(path[i])) {
0703:                        try {
0704:                            urls.add(SVNURL.parseURIEncoded(path[i]));
0705:                        } catch (SVNException e) {
0706:                            throwException(e);
0707:                        }
0708:                    } else {
0709:                        paths.add(new File(path[i]));
0710:                    }
0711:                }
0712:                SVNURL[] svnURLs = (SVNURL[]) urls.toArray(new SVNURL[urls
0713:                        .size()]);
0714:                File[] files = (File[]) paths.toArray(new File[paths.size()]);
0715:                if (svnURLs.length > 0) {
0716:                    try {
0717:                        client.doMkDir(svnURLs, message);
0718:                    } catch (SVNException e) {
0719:                        throwException(e);
0720:                    }
0721:                }
0722:                if (files.length > 0) {
0723:                    for (int i = 0; i < files.length; i++) {
0724:                        File file = files[i];
0725:                        try {
0726:                            getSVNWCClient().doAdd(file, false, true, false,
0727:                                    false, false);
0728:                        } catch (SVNException e) {
0729:                            throwException(e);
0730:                        }
0731:                    }
0732:                }
0733:            }
0734:
0735:            public void cleanup(String path) throws ClientException {
0736:                SVNWCClient client = getSVNWCClient();
0737:                try {
0738:                    client.doCleanup(new File(path).getAbsoluteFile());
0739:                } catch (SVNException e) {
0740:                    throwException(e);
0741:                }
0742:            }
0743:
0744:            public void resolved(String path, boolean recurse)
0745:                    throws ClientException {
0746:                SVNWCClient client = getSVNWCClient();
0747:                try {
0748:                    client.doResolve(new File(path).getAbsoluteFile(), recurse);
0749:                } catch (SVNException e) {
0750:                    throwException(e);
0751:                }
0752:            }
0753:
0754:            public long doExport(String srcPath, String destPath,
0755:                    Revision revision, boolean force) throws ClientException {
0756:                return doExport(srcPath, destPath, revision, null, force,
0757:                        false, true, "");
0758:            }
0759:
0760:            public long doExport(String srcPath, String destPath,
0761:                    Revision revision, Revision pegRevision, boolean force,
0762:                    boolean ignoreExternals, boolean recurse, String nativeEOL)
0763:                    throws ClientException {
0764:                SVNUpdateClient updater = getSVNUpdateClient();
0765:                boolean oldIgnore = updater.isIgnoreExternals();
0766:                updater.setIgnoreExternals(ignoreExternals);
0767:                try {
0768:                    if (isURL(srcPath)) {
0769:                        return updater
0770:                                .doExport(SVNURL.parseURIEncoded(srcPath),
0771:                                        new File(destPath).getAbsoluteFile(),
0772:                                        JavaHLObjectFactory
0773:                                                .getSVNRevision(pegRevision),
0774:                                        JavaHLObjectFactory
0775:                                                .getSVNRevision(revision),
0776:                                        nativeEOL, force, recurse);
0777:                    }
0778:                    return updater.doExport(
0779:                            new File(srcPath).getAbsoluteFile(), new File(
0780:                                    destPath).getAbsoluteFile(),
0781:                            JavaHLObjectFactory.getSVNRevision(pegRevision),
0782:                            JavaHLObjectFactory.getSVNRevision(revision),
0783:                            nativeEOL, force, recurse);
0784:                } catch (SVNException e) {
0785:                    throwException(e);
0786:                } finally {
0787:                    updater.setIgnoreExternals(oldIgnore);
0788:                }
0789:                return -1;
0790:            }
0791:
0792:            public long doSwitch(String path, String url, Revision revision,
0793:                    boolean recurse) throws ClientException {
0794:                SVNUpdateClient updater = getSVNUpdateClient();
0795:                try {
0796:                    return updater.doSwitch(new File(path).getAbsoluteFile(),
0797:                            SVNURL.parseURIEncoded(url), JavaHLObjectFactory
0798:                                    .getSVNRevision(revision), recurse);
0799:                } catch (SVNException e) {
0800:                    throwException(e);
0801:                }
0802:                return -1;
0803:            }
0804:
0805:            public void doImport(String path, String url, String message,
0806:                    boolean recurse) throws ClientException {
0807:                SVNCommitClient commitClient = getSVNCommitClient();
0808:                try {
0809:                    commitClient.doImport(new File(path), SVNURL
0810:                            .parseURIEncoded(url), message, recurse);
0811:                } catch (SVNException e) {
0812:                    throwException(e);
0813:                }
0814:            }
0815:
0816:            public void merge(String path1, Revision revision1, String path2,
0817:                    Revision revision2, String localPath, boolean force,
0818:                    boolean recurse) throws ClientException {
0819:                merge(path1, revision1, path2, revision2, localPath, force,
0820:                        recurse, false, false);
0821:            }
0822:
0823:            public void merge(String path1, Revision revision1, String path2,
0824:                    Revision revision2, String localPath, boolean force,
0825:                    boolean recurse, boolean ignoreAncestry, boolean dryRun)
0826:                    throws ClientException {
0827:                SVNDiffClient differ = getSVNDiffClient();
0828:                try {
0829:                    if (isURL(path1) && isURL(path2)) {
0830:                        SVNURL url1 = SVNURL.parseURIEncoded(path1);
0831:                        SVNURL url2 = SVNURL.parseURIEncoded(path2);
0832:                        differ.doMerge(url1, JavaHLObjectFactory
0833:                                .getSVNRevision(revision1), url2,
0834:                                JavaHLObjectFactory.getSVNRevision(revision2),
0835:                                new File(localPath).getAbsoluteFile(), recurse,
0836:                                !ignoreAncestry, force, dryRun);
0837:                    } else if (isURL(path1)) {
0838:                        SVNURL url1 = SVNURL.parseURIEncoded(path1);
0839:                        File file2 = new File(path2).getAbsoluteFile();
0840:                        differ.doMerge(url1, JavaHLObjectFactory
0841:                                .getSVNRevision(revision1), file2,
0842:                                JavaHLObjectFactory.getSVNRevision(revision2),
0843:                                new File(localPath).getAbsoluteFile(), recurse,
0844:                                !ignoreAncestry, force, dryRun);
0845:                    } else if (isURL(path2)) {
0846:                        SVNURL url2 = SVNURL.parseURIEncoded(path2);
0847:                        File file1 = new File(path1).getAbsoluteFile();
0848:                        differ.doMerge(file1, JavaHLObjectFactory
0849:                                .getSVNRevision(revision1), url2,
0850:                                JavaHLObjectFactory.getSVNRevision(revision2),
0851:                                new File(localPath).getAbsoluteFile(), recurse,
0852:                                !ignoreAncestry, force, dryRun);
0853:                    } else {
0854:                        File file1 = new File(path1).getAbsoluteFile();
0855:                        File file2 = new File(path2).getAbsoluteFile();
0856:                        differ.doMerge(file1, JavaHLObjectFactory
0857:                                .getSVNRevision(revision1), file2,
0858:                                JavaHLObjectFactory.getSVNRevision(revision2),
0859:                                new File(localPath).getAbsoluteFile(), recurse,
0860:                                !ignoreAncestry, force, dryRun);
0861:                    }
0862:                } catch (SVNException e) {
0863:                    throwException(e);
0864:                }
0865:            }
0866:
0867:            public void merge(String path, Revision pegRevision,
0868:                    Revision revision1, Revision revision2, String localPath,
0869:                    boolean force, boolean recurse, boolean ignoreAncestry,
0870:                    boolean dryRun) throws ClientException {
0871:                SVNDiffClient differ = getSVNDiffClient();
0872:                try {
0873:                    if (isURL(path)) {
0874:                        SVNURL url = SVNURL.parseURIEncoded(path);
0875:                        differ.doMerge(url, JavaHLObjectFactory
0876:                                .getSVNRevision(pegRevision),
0877:                                JavaHLObjectFactory.getSVNRevision(revision1),
0878:                                JavaHLObjectFactory.getSVNRevision(revision2),
0879:                                new File(localPath).getAbsoluteFile(), recurse,
0880:                                !ignoreAncestry, force, dryRun);
0881:                    } else {
0882:                        differ
0883:                                .doMerge(new File(path).getAbsoluteFile(),
0884:                                        JavaHLObjectFactory
0885:                                                .getSVNRevision(pegRevision),
0886:                                        JavaHLObjectFactory
0887:                                                .getSVNRevision(revision1),
0888:                                        JavaHLObjectFactory
0889:                                                .getSVNRevision(revision2),
0890:                                        new File(localPath).getAbsoluteFile(),
0891:                                        recurse, !ignoreAncestry, force, dryRun);
0892:                    }
0893:                } catch (SVNException e) {
0894:                    throwException(e);
0895:                }
0896:            }
0897:
0898:            public void diff(String target1, Revision revision1,
0899:                    String target2, Revision revision2, String outFileName,
0900:                    boolean recurse) throws ClientException {
0901:                diff(target1, revision1, target2, revision2, outFileName,
0902:                        recurse, false, false, false);
0903:            }
0904:
0905:            public void diff(String target1, Revision revision1,
0906:                    String target2, Revision revision2, String outFileName,
0907:                    boolean recurse, boolean ignoreAncestry,
0908:                    boolean noDiffDeleted, boolean force)
0909:                    throws ClientException {
0910:                SVNDiffClient differ = getSVNDiffClient();
0911:                differ.getDiffGenerator().setDiffDeleted(!noDiffDeleted);
0912:                differ.getDiffGenerator().setForcedBinaryDiff(force);
0913:                SVNRevision rev1 = JavaHLObjectFactory
0914:                        .getSVNRevision(revision1);
0915:                SVNRevision rev2 = JavaHLObjectFactory
0916:                        .getSVNRevision(revision2);
0917:                try {
0918:                    OutputStream out = SVNFileUtil.openFileForWriting(new File(
0919:                            outFileName));
0920:                    if (!isURL(target1) && !isURL(target2)) {
0921:                        differ.doDiff(new File(target1).getAbsoluteFile(),
0922:                                rev1, new File(target2).getAbsoluteFile(),
0923:                                rev2, recurse, !ignoreAncestry, out);
0924:                    } else if (isURL(target1) && isURL(target2)) {
0925:                        SVNURL url1 = SVNURL.parseURIEncoded(target1);
0926:                        SVNURL url2 = SVNURL.parseURIEncoded(target2);
0927:                        differ.doDiff(url1, rev1, url2, rev2, recurse,
0928:                                !ignoreAncestry, out);
0929:                    } else if (!isURL(target1) && isURL(target2)) {
0930:                        SVNURL url2 = SVNURL.parseURIEncoded(target2);
0931:                        differ
0932:                                .doDiff(new File(target1).getAbsoluteFile(),
0933:                                        rev1, url2, rev2, recurse,
0934:                                        !ignoreAncestry, out);
0935:                    } else if (isURL(target1) && !isURL(target2)) {
0936:                        SVNURL url1 = SVNURL.parseURIEncoded(target1);
0937:                        differ.doDiff(url1, rev1, new File(target2)
0938:                                .getAbsoluteFile(), rev2, recurse,
0939:                                !ignoreAncestry, out);
0940:                    }
0941:                    SVNFileUtil.closeFile(out);
0942:                } catch (SVNException e) {
0943:                    throwException(e);
0944:                }
0945:            }
0946:
0947:            public void diff(String target, Revision pegRevision,
0948:                    Revision startRevision, Revision endRevision,
0949:                    String outFileName, boolean recurse,
0950:                    boolean ignoreAncestry, boolean noDiffDeleted, boolean force)
0951:                    throws ClientException {
0952:                SVNDiffClient differ = getSVNDiffClient();
0953:                differ.getDiffGenerator().setDiffDeleted(!noDiffDeleted);
0954:                differ.getDiffGenerator().setForcedBinaryDiff(force);
0955:                SVNRevision peg = JavaHLObjectFactory
0956:                        .getSVNRevision(pegRevision);
0957:                SVNRevision rev1 = JavaHLObjectFactory
0958:                        .getSVNRevision(startRevision);
0959:                SVNRevision rev2 = JavaHLObjectFactory
0960:                        .getSVNRevision(endRevision);
0961:                try {
0962:                    OutputStream out = SVNFileUtil.openFileForWriting(new File(
0963:                            outFileName));
0964:
0965:                    if (isURL(target)) {
0966:                        SVNURL url = SVNURL.parseURIEncoded(target);
0967:                        differ.doDiff(url, peg, rev1, rev2, recurse,
0968:                                !ignoreAncestry, out);
0969:                    } else {
0970:                        differ.doDiff(new File(target).getAbsoluteFile(), peg,
0971:                                rev1, rev2, recurse, !ignoreAncestry, out);
0972:                    }
0973:                    SVNFileUtil.closeFile(out);
0974:                } catch (SVNException e) {
0975:                    throwException(e);
0976:                }
0977:            }
0978:
0979:            public PropertyData[] properties(String path)
0980:                    throws ClientException {
0981:                return properties(path, null, null);
0982:            }
0983:
0984:            public PropertyData[] properties(String path, Revision revision)
0985:                    throws ClientException {
0986:                return properties(path, revision, null);
0987:            }
0988:
0989:            public PropertyData[] properties(String path, Revision revision,
0990:                    Revision pegRevision) throws ClientException {
0991:                if (path == null) {
0992:                    return null;
0993:                }
0994:                SVNWCClient client = getSVNWCClient();
0995:                SVNRevision svnRevision = JavaHLObjectFactory
0996:                        .getSVNRevision(revision);
0997:                SVNRevision svnPegRevision = JavaHLObjectFactory
0998:                        .getSVNRevision(pegRevision);
0999:                JavaHLPropertyHandler propHandler = new JavaHLPropertyHandler(
1000:                        myOwner);
1001:                try {
1002:                    if (isURL(path)) {
1003:                        client.doGetProperty(SVNURL.parseURIEncoded(path),
1004:                                null, svnPegRevision, svnRevision, false,
1005:                                propHandler);
1006:                    } else {
1007:                        client.doGetProperty(new File(path).getAbsoluteFile(),
1008:                                null, svnPegRevision, svnRevision, false,
1009:                                propHandler);
1010:                    }
1011:                } catch (SVNException e) {
1012:                    throwException(e);
1013:                }
1014:                return propHandler.getAllPropertyData();
1015:            }
1016:
1017:            public void propertySet(String path, String name, byte[] value,
1018:                    boolean recurse) throws ClientException {
1019:                propertySet(path, name, new String(value), recurse);
1020:            }
1021:
1022:            public void propertySet(String path, String name, byte[] value,
1023:                    boolean recurse, boolean force) throws ClientException {
1024:                propertySet(path, name, new String(value), recurse, force);
1025:            }
1026:
1027:            public void propertySet(String path, String name, String value,
1028:                    boolean recurse) throws ClientException {
1029:                propertySet(path, name, value, recurse, false);
1030:            }
1031:
1032:            public void propertySet(String path, String name, String value,
1033:                    boolean recurse, boolean force) throws ClientException {
1034:                SVNWCClient client = getSVNWCClient();
1035:                try {
1036:                    client.doSetProperty(new File(path).getAbsoluteFile(),
1037:                            name, value, force, recurse,
1038:                            ISVNPropertyHandler.NULL);
1039:                } catch (SVNException e) {
1040:                    throwException(e);
1041:                }
1042:            }
1043:
1044:            public void propertyRemove(String path, String name, boolean recurse)
1045:                    throws ClientException {
1046:                SVNWCClient client = getSVNWCClient();
1047:                try {
1048:                    client.doSetProperty(new File(path).getAbsoluteFile(),
1049:                            name, null, false, recurse,
1050:                            ISVNPropertyHandler.NULL);
1051:                } catch (SVNException e) {
1052:                    throwException(e);
1053:                }
1054:            }
1055:
1056:            public void propertyCreate(String path, String name, String value,
1057:                    boolean recurse) throws ClientException {
1058:                propertyCreate(path, name, value, recurse, false);
1059:            }
1060:
1061:            public void propertyCreate(String path, String name, String value,
1062:                    boolean recurse, boolean force) throws ClientException {
1063:                if (value == null) {
1064:                    value = "";
1065:                }
1066:                SVNWCClient client = getSVNWCClient();
1067:                try {
1068:                    client.doSetProperty(new File(path).getAbsoluteFile(),
1069:                            name, value, force, recurse,
1070:                            ISVNPropertyHandler.NULL);
1071:                } catch (SVNException e) {
1072:                    throwException(e);
1073:                }
1074:            }
1075:
1076:            public void propertyCreate(String path, String name, byte[] value,
1077:                    boolean recurse) throws ClientException {
1078:                propertyCreate(path, name, value == null ? null : new String(
1079:                        value), recurse);
1080:            }
1081:
1082:            public void propertyCreate(String path, String name, byte[] value,
1083:                    boolean recurse, boolean force) throws ClientException {
1084:                propertyCreate(path, name, value == null ? null : new String(
1085:                        value), recurse, force);
1086:            }
1087:
1088:            public PropertyData revProperty(String path, String name,
1089:                    Revision rev) throws ClientException {
1090:                if (name == null || name.equals("")) {
1091:                    return null;
1092:                }
1093:                SVNWCClient client = getSVNWCClient();
1094:                SVNRevision svnRevision = JavaHLObjectFactory
1095:                        .getSVNRevision(rev);
1096:                JavaHLPropertyHandler retriever = new JavaHLPropertyHandler(
1097:                        myOwner);
1098:                try {
1099:                    if (isURL(path)) {
1100:                        client.doGetRevisionProperty(SVNURL
1101:                                .parseURIEncoded(path), name, svnRevision,
1102:                                retriever);
1103:                    } else {
1104:                        client.doGetRevisionProperty(new File(path)
1105:                                .getAbsoluteFile(), name, svnRevision,
1106:                                retriever);
1107:                    }
1108:                } catch (SVNException e) {
1109:                    throwException(e);
1110:                }
1111:                return retriever.getPropertyData();
1112:            }
1113:
1114:            public PropertyData[] revProperties(String path, Revision rev)
1115:                    throws ClientException {
1116:                if (path == null) {
1117:                    return null;
1118:                }
1119:                SVNWCClient client = getSVNWCClient();
1120:                SVNRevision svnRevision = JavaHLObjectFactory
1121:                        .getSVNRevision(rev);
1122:                JavaHLPropertyHandler propHandler = new JavaHLPropertyHandler(
1123:                        myOwner);
1124:                try {
1125:                    if (isURL(path)) {
1126:                        client.doGetRevisionProperty(SVNURL
1127:                                .parseURIEncoded(path), null, svnRevision,
1128:                                propHandler);
1129:                    } else {
1130:                        client.doGetRevisionProperty(new File(path)
1131:                                .getAbsoluteFile(), null, svnRevision,
1132:                                propHandler);
1133:                    }
1134:                } catch (SVNException e) {
1135:                    throwException(e);
1136:                }
1137:                return propHandler.getAllPropertyData();
1138:            }
1139:
1140:            public void setRevProperty(String path, String name, Revision rev,
1141:                    String value, boolean force) throws ClientException {
1142:                if (name == null || name.equals("")) {
1143:                    return;
1144:                }
1145:                SVNWCClient client = getSVNWCClient();
1146:                SVNRevision svnRevision = JavaHLObjectFactory
1147:                        .getSVNRevision(rev);
1148:                try {
1149:                    if (isURL(path)) {
1150:                        client.doSetRevisionProperty(SVNURL
1151:                                .parseURIEncoded(path), svnRevision, name,
1152:                                value, force, ISVNPropertyHandler.NULL);
1153:                    } else {
1154:                        client.doSetRevisionProperty(new File(path)
1155:                                .getAbsoluteFile(), svnRevision, name, value,
1156:                                force, ISVNPropertyHandler.NULL);
1157:                    }
1158:                } catch (SVNException e) {
1159:                    throwException(e);
1160:                }
1161:            }
1162:
1163:            public PropertyData propertyGet(String path, String name)
1164:                    throws ClientException {
1165:                return propertyGet(path, name, null);
1166:            }
1167:
1168:            public PropertyData propertyGet(String path, String name,
1169:                    Revision revision) throws ClientException {
1170:                return propertyGet(path, name, revision, null);
1171:            }
1172:
1173:            public PropertyData propertyGet(String path, String name,
1174:                    Revision revision, Revision pegRevision)
1175:                    throws ClientException {
1176:                if (name == null || name.equals("")) {
1177:                    return null;
1178:                }
1179:                SVNWCClient client = getSVNWCClient();
1180:                SVNRevision svnRevision = JavaHLObjectFactory
1181:                        .getSVNRevision(revision);
1182:                SVNRevision svnPegRevision = JavaHLObjectFactory
1183:                        .getSVNRevision(pegRevision);
1184:                JavaHLPropertyHandler retriever = new JavaHLPropertyHandler(
1185:                        myOwner);
1186:                try {
1187:                    if (isURL(path)) {
1188:                        client.doGetProperty(SVNURL.parseURIEncoded(path),
1189:                                name, svnPegRevision, svnRevision, false,
1190:                                retriever);
1191:                    } else {
1192:                        client.doGetProperty(new File(path).getAbsoluteFile(),
1193:                                name, svnPegRevision, svnRevision, false,
1194:                                retriever);
1195:                    }
1196:                } catch (SVNException e) {
1197:                    throwException(e);
1198:                }
1199:                return retriever.getPropertyData();
1200:            }
1201:
1202:            public byte[] fileContent(String path, Revision revision)
1203:                    throws ClientException {
1204:                return fileContent(path, revision, null);
1205:            }
1206:
1207:            public byte[] fileContent(String path, Revision revision,
1208:                    Revision pegRevision) throws ClientException {
1209:                SVNWCClient client = getSVNWCClient();
1210:                try {
1211:                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
1212:                    if (isURL(path)) {
1213:                        client
1214:                                .doGetFileContents(
1215:                                        SVNURL.parseURIEncoded(path),
1216:                                        JavaHLObjectFactory
1217:                                                .getSVNRevision(pegRevision),
1218:                                        JavaHLObjectFactory
1219:                                                .getSVNRevision(revision),
1220:                                        true, baos);
1221:                    } else {
1222:                        client.doGetFileContents(new File(path)
1223:                                .getAbsoluteFile(), JavaHLObjectFactory
1224:                                .getSVNRevision(pegRevision),
1225:                                JavaHLObjectFactory.getSVNRevision(revision),
1226:                                true, baos);
1227:                    }
1228:                    return baos.toByteArray();
1229:                } catch (SVNException e) {
1230:                    throwException(e);
1231:                }
1232:                return null;
1233:            }
1234:
1235:            public void streamFileContent(String path, Revision revision,
1236:                    Revision pegRevision, int bufferSize, OutputStream stream)
1237:                    throws ClientException {
1238:                SVNWCClient client = getSVNWCClient();
1239:                try {
1240:                    if (isURL(path)) {
1241:                        client
1242:                                .doGetFileContents(
1243:                                        SVNURL.parseURIEncoded(path),
1244:                                        JavaHLObjectFactory
1245:                                                .getSVNRevision(pegRevision),
1246:                                        JavaHLObjectFactory
1247:                                                .getSVNRevision(revision),
1248:                                        true, stream);
1249:                    } else {
1250:                        client.doGetFileContents(new File(path)
1251:                                .getAbsoluteFile(), JavaHLObjectFactory
1252:                                .getSVNRevision(pegRevision),
1253:                                JavaHLObjectFactory.getSVNRevision(revision),
1254:                                true, stream);
1255:                    }
1256:                } catch (SVNException e) {
1257:                    throwException(e);
1258:                }
1259:            }
1260:
1261:            public void relocate(String from, String to, String path,
1262:                    boolean recurse) throws ClientException {
1263:                SVNUpdateClient client = getSVNUpdateClient();
1264:                try {
1265:                    client.doRelocate(new File(path).getAbsoluteFile(), SVNURL
1266:                            .parseURIEncoded(from), SVNURL.parseURIEncoded(to),
1267:                            recurse);
1268:                } catch (SVNException e) {
1269:                    throwException(e);
1270:                }
1271:            }
1272:
1273:            public byte[] blame(String path, Revision revisionStart,
1274:                    Revision revisionEnd) throws ClientException {
1275:                SVNLogClient client = getSVNLogClient();
1276:                final ByteArrayOutputStream baos = new ByteArrayOutputStream();
1277:                ISVNAnnotateHandler handler = new ISVNAnnotateHandler() {
1278:                    public void handleLine(Date date, long revision,
1279:                            String author, String line) {
1280:                        StringBuffer result = new StringBuffer();
1281:                        result.append(Long.toString(revision));
1282:                        result
1283:                                .append(author != null ? SVNFormatUtil
1284:                                        .formatString(author, 10, false)
1285:                                        : "         -");
1286:                        result.append(' ');
1287:                        result.append(line);
1288:                        try {
1289:                            baos.write(result.toString().getBytes());
1290:                            baos.write('\n');
1291:                        } catch (IOException e) {
1292:                        }
1293:                    }
1294:                };
1295:                try {
1296:                    if (isURL(path)) {
1297:                        client
1298:                                .doAnnotate(SVNURL.parseURIEncoded(path),
1299:                                        SVNRevision.UNDEFINED,
1300:                                        JavaHLObjectFactory
1301:                                                .getSVNRevision(revisionStart),
1302:                                        JavaHLObjectFactory
1303:                                                .getSVNRevision(revisionEnd),
1304:                                        handler);
1305:                    } else {
1306:                        client
1307:                                .doAnnotate(new File(path).getAbsoluteFile(),
1308:                                        SVNRevision.UNDEFINED,
1309:                                        JavaHLObjectFactory
1310:                                                .getSVNRevision(revisionStart),
1311:                                        JavaHLObjectFactory
1312:                                                .getSVNRevision(revisionEnd),
1313:                                        handler);
1314:                    }
1315:                } catch (SVNException e) {
1316:                    throwException(e);
1317:                }
1318:                return baos.toByteArray();
1319:            }
1320:
1321:            public void blame(String path, Revision revisionStart,
1322:                    Revision revisionEnd, BlameCallback callback)
1323:                    throws ClientException {
1324:                blame(path, null, revisionStart, revisionEnd, callback);
1325:            }
1326:
1327:            public void blame(String path, Revision pegRevision,
1328:                    Revision revisionStart, Revision revisionEnd,
1329:                    final BlameCallback callback) throws ClientException {
1330:                SVNLogClient client = getSVNLogClient();
1331:                ISVNAnnotateHandler handler = new ISVNAnnotateHandler() {
1332:                    public void handleLine(Date date, long revision,
1333:                            String author, String line) {
1334:                        if (callback != null) {
1335:                            callback.singleLine(date, revision, author, line);
1336:                        }
1337:                    }
1338:                };
1339:                try {
1340:                    if (isURL(path)) {
1341:                        client
1342:                                .doAnnotate(SVNURL.parseURIEncoded(path),
1343:                                        JavaHLObjectFactory
1344:                                                .getSVNRevision(pegRevision),
1345:                                        JavaHLObjectFactory
1346:                                                .getSVNRevision(revisionStart),
1347:                                        JavaHLObjectFactory
1348:                                                .getSVNRevision(revisionEnd),
1349:                                        handler);
1350:                    } else {
1351:                        client
1352:                                .doAnnotate(new File(path).getAbsoluteFile(),
1353:                                        JavaHLObjectFactory
1354:                                                .getSVNRevision(pegRevision),
1355:                                        JavaHLObjectFactory
1356:                                                .getSVNRevision(revisionStart),
1357:                                        JavaHLObjectFactory
1358:                                                .getSVNRevision(revisionEnd),
1359:                                        handler);
1360:                    }
1361:                } catch (SVNException e) {
1362:                    throwException(e);
1363:                }
1364:            }
1365:
1366:            public void dispose() {
1367:                if (myClientManager != null) {
1368:                    myClientManager.dispose();
1369:                    myClientManager = null;
1370:                }
1371:                synchronized (SVNClientImpl.class) {
1372:                    ourInstanceCount--;
1373:                    if (ourInstanceCount <= 0) {
1374:                        ourInstanceCount = 0;
1375:                        SVNSSHSession.shutdown();
1376:                    }
1377:                }
1378:                // stop tracking me!
1379:                SVNClientImplTracker.deregisterClient(this );
1380:            }
1381:
1382:            public void setConfigDirectory(String configDir)
1383:                    throws ClientException {
1384:                myConfigDir = configDir;
1385:                updateClientManager();
1386:            }
1387:
1388:            public String getConfigDirectory() throws ClientException {
1389:                return myConfigDir;
1390:            }
1391:
1392:            public void cancelOperation() throws ClientException {
1393:                myCancelOperation = true;
1394:            }
1395:
1396:            public Info info(String path) throws ClientException {
1397:                SVNWCClient client = getSVNWCClient();
1398:                try {
1399:                    if (isURL(path)) {
1400:                        return JavaHLObjectFactory.createInfo(client.doInfo(
1401:                                SVNURL.parseURIEncoded(path),
1402:                                SVNRevision.UNDEFINED, SVNRevision.UNDEFINED));
1403:                    }
1404:                    return JavaHLObjectFactory.createInfo(client.doInfo(
1405:                            new File(path).getAbsoluteFile(),
1406:                            SVNRevision.UNDEFINED));
1407:                } catch (SVNException e) {
1408:                    if (e.getErrorMessage().getErrorCode() == SVNErrorCode.UNVERSIONED_RESOURCE) {
1409:                        return null;
1410:                    }
1411:                    throwException(e);
1412:                }
1413:                return null;
1414:            }
1415:
1416:            public void lock(String[] path, String comment, boolean force)
1417:                    throws ClientException {
1418:                boolean allFiles = true;
1419:                for (int i = 0; i < path.length; i++) {
1420:                    allFiles = allFiles && !isURL(path[i]);
1421:                }
1422:                try {
1423:                    if (allFiles) {
1424:                        File[] files = new File[path.length];
1425:                        for (int i = 0; i < files.length; i++) {
1426:                            files[i] = new File(path[i]).getAbsoluteFile();
1427:                        }
1428:                        getSVNWCClient().doLock(files, force, comment);
1429:                    } else {
1430:                        SVNURL[] urls = new SVNURL[path.length];
1431:                        for (int i = 0; i < urls.length; i++) {
1432:                            urls[i] = SVNURL.parseURIEncoded(path[i]);
1433:                        }
1434:                        getSVNWCClient().doLock(urls, force, comment);
1435:                    }
1436:                } catch (SVNException e) {
1437:                    throwException(e);
1438:                }
1439:            }
1440:
1441:            public void unlock(String[] path, boolean force)
1442:                    throws ClientException {
1443:                boolean allFiles = true;
1444:                for (int i = 0; i < path.length; i++) {
1445:                    allFiles = allFiles && !isURL(path[i]);
1446:                }
1447:                try {
1448:                    if (allFiles) {
1449:                        File[] files = new File[path.length];
1450:                        for (int i = 0; i < files.length; i++) {
1451:                            files[i] = new File(path[i]).getAbsoluteFile();
1452:                        }
1453:                        getSVNWCClient().doUnlock(files, force);
1454:                    } else {
1455:                        SVNURL[] urls = new SVNURL[path.length];
1456:                        for (int i = 0; i < urls.length; i++) {
1457:                            urls[i] = SVNURL.parseURIEncoded(path[i]);
1458:                        }
1459:                        getSVNWCClient().doUnlock(urls, force);
1460:                    }
1461:                } catch (SVNException e) {
1462:                    throwException(e);
1463:                }
1464:            }
1465:
1466:            public Info2[] info2(String pathOrUrl, Revision revision,
1467:                    Revision pegRevision, boolean recurse)
1468:                    throws ClientException {
1469:                SVNWCClient client = getSVNWCClient();
1470:                final Collection infos = new ArrayList();
1471:                ISVNInfoHandler handler = new ISVNInfoHandler() {
1472:                    public void handleInfo(SVNInfo info) {
1473:                        infos.add(JavaHLObjectFactory.createInfo2(info));
1474:                    }
1475:                };
1476:                try {
1477:                    if (isURL(pathOrUrl)) {
1478:                        client
1479:                                .doInfo(SVNURL.parseURIEncoded(pathOrUrl),
1480:                                        JavaHLObjectFactory
1481:                                                .getSVNRevision(pegRevision),
1482:                                        JavaHLObjectFactory
1483:                                                .getSVNRevision(revision),
1484:                                        recurse, handler);
1485:                    } else {
1486:                        client.doInfo(new File(pathOrUrl).getAbsoluteFile(),
1487:                                JavaHLObjectFactory.getSVNRevision(revision),
1488:                                recurse, handler);
1489:                    }
1490:                    return (Info2[]) infos.toArray(new Info2[infos.size()]);
1491:                } catch (SVNException e) {
1492:                    if (e.getErrorMessage().getErrorCode() == SVNErrorCode.UNVERSIONED_RESOURCE) {
1493:                        return new Info2[0];
1494:                    }
1495:                    throwException(e);
1496:                }
1497:                return null;
1498:            }
1499:
1500:            public String getVersionInfo(String path, String trailUrl,
1501:                    boolean lastChanged) throws ClientException {
1502:                try {
1503:                    return getSVNWCClient().doGetWorkingCopyID(
1504:                            new File(path).getAbsoluteFile(), trailUrl);
1505:                } catch (SVNException e) {
1506:                    throwException(e);
1507:                }
1508:                return null;
1509:            }
1510:
1511:            public static String version() {
1512:                return Version.getVersionString();
1513:            }
1514:
1515:            public static int versionMajor() {
1516:                return Version.getMajorVersion();
1517:            }
1518:
1519:            public static int versionMinor() {
1520:                return Version.getMinorVersion();
1521:            }
1522:
1523:            public static int versionMicro() {
1524:                return Version.getMicroVersion();
1525:            }
1526:
1527:            /**
1528:             * @deprecated
1529:             */
1530:            protected Notify getNotify() {
1531:                return myNotify;
1532:            }
1533:
1534:            protected Notify2 getNotify2() {
1535:                return myNotify2;
1536:            }
1537:
1538:            protected ISVNEventHandler getEventListener() {
1539:                if (mySVNEventListener == null) {
1540:                    mySVNEventListener = new ISVNEventHandler() {
1541:
1542:                        public void handleEvent(SVNEvent event, double progress) {
1543:                            String path = event.getFile() == null ? event
1544:                                    .getPath() : event.getFile()
1545:                                    .getAbsolutePath();
1546:                            if (path != null) {
1547:                                path = path.replace(File.separatorChar, '/');
1548:                            }
1549:                            if (myNotify != null
1550:                                    && event.getErrorMessage() == null) {
1551:                                myNotify
1552:                                        .onNotify(
1553:                                                path,
1554:                                                JavaHLObjectFactory
1555:                                                        .getNotifyActionValue(event
1556:                                                                .getAction()),
1557:                                                JavaHLObjectFactory
1558:                                                        .getNodeKind(event
1559:                                                                .getNodeKind()),
1560:                                                event.getMimeType(),
1561:                                                JavaHLObjectFactory
1562:                                                        .getStatusValue(event
1563:                                                                .getContentsStatus()),
1564:                                                JavaHLObjectFactory
1565:                                                        .getStatusValue(event
1566:                                                                .getPropertiesStatus()),
1567:                                                event.getRevision());
1568:                            }
1569:                            if (myNotify2 != null) {
1570:                                NotifyInformation info = JavaHLObjectFactory
1571:                                        .createNotifyInformation(event, path);
1572:                                myNotify2.onNotify(info);
1573:                            }
1574:                        }
1575:
1576:                        public void checkCancelled() throws SVNCancelException {
1577:                            if (myCancelOperation) {
1578:                                myCancelOperation = false;
1579:                                SVNErrorManager.cancel("operation cancelled");
1580:                            }
1581:                        }
1582:                    };
1583:                }
1584:                return mySVNEventListener;
1585:            }
1586:
1587:            public SVNClientManager getClientManager() {
1588:                if (myClientManager == null) {
1589:                    updateClientManager();
1590:                    myClientManager = SVNClientManager.newInstance(myOptions,
1591:                            new DefaultSVNRepositoryPool(
1592:                                    myAuthenticationManager, myOptions));
1593:                    myClientManager.setEventHandler(getEventListener());
1594:                }
1595:                return myClientManager;
1596:            }
1597:
1598:            protected SVNCommitClient getSVNCommitClient() {
1599:                return getClientManager().getCommitClient();
1600:            }
1601:
1602:            protected SVNUpdateClient getSVNUpdateClient() {
1603:                return getClientManager().getUpdateClient();
1604:            }
1605:
1606:            protected SVNStatusClient getSVNStatusClient() {
1607:                return getClientManager().getStatusClient();
1608:            }
1609:
1610:            protected SVNWCClient getSVNWCClient() {
1611:                return getClientManager().getWCClient();
1612:            }
1613:
1614:            protected SVNDiffClient getSVNDiffClient() {
1615:                return getClientManager().getDiffClient();
1616:            }
1617:
1618:            protected SVNCopyClient getSVNCopyClient() {
1619:                return getClientManager().getCopyClient();
1620:            }
1621:
1622:            protected SVNLogClient getSVNLogClient() {
1623:                return getClientManager().getLogClient();
1624:            }
1625:
1626:            protected CommitMessage getCommitMessage() {
1627:                return myMessageHandler;
1628:            }
1629:
1630:            protected void throwException(SVNException e)
1631:                    throws ClientException {
1632:                JavaHLObjectFactory.throwException(e, this );
1633:            }
1634:
1635:            protected static boolean isURL(String pathOrUrl) {
1636:                pathOrUrl = pathOrUrl != null ? pathOrUrl.toLowerCase() : null;
1637:                return pathOrUrl != null
1638:                        && (pathOrUrl.startsWith("http://")
1639:                                || pathOrUrl.startsWith("https://")
1640:                                || pathOrUrl.startsWith("svn://")
1641:                                || (pathOrUrl.startsWith("svn+") && pathOrUrl
1642:                                        .indexOf("://") > 4) || pathOrUrl
1643:                                .startsWith("file://"));
1644:            }
1645:
1646:            public String getAdminDirectoryName() {
1647:                return SVNFileUtil.getAdminDirectoryName();
1648:            }
1649:
1650:            public boolean isAdminDirectory(String name) {
1651:                return name != null && (SVNFileUtil.isWindows) ? name
1652:                        .equalsIgnoreCase(SVNFileUtil.getAdminDirectoryName())
1653:                        : name.equals(SVNFileUtil.getAdminDirectoryName());
1654:            }
1655:
1656:            public org.tigris.subversion.javahl.Version getVersion() {
1657:                return SVNClientImplVersion.getInstance();
1658:            }
1659:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.