Subversion Repositories XServices

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
113 brianR 1
/*     */ package net.brutex.xservices.util;
2
/*     */
3
/*     */ import java.io.File;
4
/*     */ import net.brutex.xservices.types.scm.ItemType;
5
/*     */ import net.brutex.xservices.ws.rs.CVSInfoImpl;
6
/*     */ import org.apache.commons.configuration.Configuration;
7
/*     */ import org.apache.commons.configuration.ConfigurationException;
8
/*     */ import org.apache.commons.configuration.PropertiesConfiguration;
9
/*     */ import org.apache.log4j.Logger;
10
/*     */ import org.netbeans.lib.cvsclient.Client;
11
/*     */ import org.netbeans.lib.cvsclient.admin.StandardAdminHandler;
12
/*     */ import org.netbeans.lib.cvsclient.command.CommandAbortedException;
13
/*     */ import org.netbeans.lib.cvsclient.command.GlobalOptions;
14
/*     */ import org.netbeans.lib.cvsclient.connection.AuthenticationException;
15
/*     */ import org.netbeans.lib.cvsclient.connection.PServerConnection;
16
/*     */
17
/*     */ public class CVSClient
18
/*     */ {
19
/*     */   private final File configfile;
20
/*     */   private final PServerConnection connection;
21
/*     */   private final CVSRoot root;
22
/*     */   private final GlobalOptions globalOptions;
23
/*  41 */   final Logger logger = Logger.getLogger(CVSInfoImpl.class);
24
/*     */   public final Client client;
25
/*     */
26
/*     */   public Client getClient()
27
/*     */   {
28
/*  49 */     return this.client;
29
/*     */   }
30
/*     */
31
/*     */   public CVSClient(File config) throws CommandAbortedException, AuthenticationException, ConfigurationException {
32
/*  53 */     System.setProperty("cvsClientLog", "c:/temp/cvs.log");
33
/*  54 */     if ((config == null) || (!config.exists()) || (config.isDirectory())) {
34
/*  55 */       throw new ConfigurationException("Config file not found");
35
/*     */     }
36
/*  57 */     this.configfile = config;
37
/*  58 */     Configuration configuration = new PropertiesConfiguration(this.configfile);
38
/*     */
39
/*  60 */     String cvsroot = configuration.getString("CVSROOT");
40
/*  61 */     String workdir = configuration.getString("WORKDIR");
41
/*  62 */     String password = configuration.getString("PASSWORD");
42
/*     */
43
/*  64 */     this.root = new CVSRoot(cvsroot);
44
/*  65 */     this.globalOptions = new GlobalOptions();
45
/*  66 */     this.globalOptions.setCVSRoot(cvsroot);
46
/*     */
47
/*  68 */     this.connection = new PServerConnection();
48
/*  69 */     this.connection.setUserName(this.root.user);
49
/*  70 */     if (password != null)
50
/*  71 */       this.connection.setEncodedPassword(CvsPassword.encode(password));
51
/*     */     else {
52
/*  73 */       this.connection.setEncodedPassword(password);
53
/*     */     }
54
/*     */
55
/*  76 */     this.connection.setHostName(this.root.host);
56
/*  77 */     this.connection.setRepository(this.root.repository);
57
/*     */     try {
58
/*  79 */       this.connection.open();
59
/*     */     } catch (AuthenticationException ex) {
60
/*  81 */       this.logger.error(ex.getMessage());
61
/*     */     }
62
/*     */
63
/*  84 */     this.client = new Client(this.connection, new StandardAdminHandler());
64
/*  85 */     this.client.setLocalPath(workdir);
65
/*     */   }
66
/*     */
67
/*     */   public File getConfigFile()
68
/*     */   {
69
/*  91 */     return this.configfile;
70
/*     */   }
71
/*     */
72
/*     */   public GlobalOptions getGlobalOptions() {
73
/*  95 */     return this.globalOptions;
74
/*     */   }
75
/*     */
76
/*     */   public PServerConnection getConnection()
77
/*     */   {
78
/* 101 */     return this.connection;
79
/*     */   }
80
/*     */
81
/*     */   public CVSRoot getRoot()
82
/*     */   {
83
/* 107 */     return this.root;
84
/*     */   }
85
/*     */
86
/*     */   public static String generateID(ItemType item) {
87
/* 111 */     return "::[" + item.getRemotename() + "]";
88
/*     */   }
89
/*     */ }
94 brianR 90
 
113 brianR 91
/* Location:           C:\Users\brosenberger\Documents\My Box Files\XBridgeNG-download\XServices-20130131 - Kopie\WEB-INF\classes\net.zip
92
 * Qualified Name:     net.brutex.xservices.util.CVSClient
93
 * JD-Core Version:    0.6.2
94
 */