Subversion Repositories XServices

Rev

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