1 package net.sf.statsvn.util.svnkit;
2
3 import java.io.File;
4
5 import net.sf.statsvn.output.SvnConfigurationOptions;
6 import net.sf.statsvn.util.ISvnDiffProcessor;
7 import net.sf.statsvn.util.ISvnInfoProcessor;
8 import net.sf.statsvn.util.ISvnProcessor;
9 import net.sf.statsvn.util.ISvnPropgetProcessor;
10 import net.sf.statsvn.util.ISvnVersionProcessor;
11
12 import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
13 import org.tmatesoft.svn.core.internal.io.fs.FSRepositoryFactory;
14 import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl;
15 import org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions;
16 import org.tmatesoft.svn.core.wc.SVNClientManager;
17 import org.tmatesoft.svn.core.wc.SVNWCUtil;
18
19 /**
20 * Base svnkit processor.
21 *
22 * @author jkealey, yogesh
23 *
24 */
25 public class SvnKitProcessor implements ISvnProcessor {
26
27
28 private File checkoutDirectory;
29 private ISvnDiffProcessor diffProcessorInstance;
30
31 private ISvnInfoProcessor infoProcessorInstance;
32 private SVNClientManager manager;
33
34 private ISvnPropgetProcessor propgetProcessorInstance;
35 private ISvnVersionProcessor versionProcessorInstance;
36
37 public File getCheckoutDirectory()
38 {
39 if (checkoutDirectory==null)
40 {
41 checkoutDirectory = SvnConfigurationOptions.getCheckedOutDirectoryAsFile();
42 }
43 return checkoutDirectory;
44 }
45 public ISvnDiffProcessor getDiffProcessor()
46 {
47 if (diffProcessorInstance==null) diffProcessorInstance = new SvnKitDiff(this);
48 return diffProcessorInstance;
49 }
50
51 public ISvnInfoProcessor getInfoProcessor()
52 {
53 if (infoProcessorInstance==null) infoProcessorInstance = new SvnKitInfo(this);
54 return infoProcessorInstance;
55 }
56 public SVNClientManager getManager()
57 {
58 if (manager==null)
59 {
60
61 DAVRepositoryFactory.setup();
62 SVNRepositoryFactoryImpl.setup();
63 FSRepositoryFactory.setup();
64
65
66 DefaultSVNOptions options = SVNWCUtil.createDefaultOptions(true);
67 options.setAuthStorageEnabled(false);
68
69
70 if (SvnConfigurationOptions.getSvnUsername()!=null && SvnConfigurationOptions.getSvnPassword()!=null)
71 manager = SVNClientManager.newInstance(options, SvnConfigurationOptions.getSvnUsername(), SvnConfigurationOptions.getSvnPassword());
72 else
73 manager = SVNClientManager.newInstance(options);
74 }
75 return manager;
76 }
77
78 public ISvnPropgetProcessor getPropgetProcessor()
79 {
80 if (propgetProcessorInstance==null) propgetProcessorInstance = new SvnKitPropget(this);
81 return propgetProcessorInstance;
82 }
83 public ISvnVersionProcessor getVersionProcessor()
84 {
85 if (versionProcessorInstance==null) versionProcessorInstance = new SvnKitVersion(this);
86 return versionProcessorInstance;
87 }
88 }