Subversion Repositories XServices

Rev

Rev 94 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 94 Rev 113
Line 1... Line -...
1
/*
-
 
2
 *   Copyright 2012 Brian Rosenberger (Brutex Network)
-
 
3
 *
-
 
4
 *   Licensed under the Apache License, Version 2.0 (the "License");
-
 
5
 *   you may not use this file except in compliance with the License.
-
 
6
 *   You may obtain a copy of the License at
-
 
7
 *
-
 
8
 *       http://www.apache.org/licenses/LICENSE-2.0
-
 
9
 *
-
 
10
 *   Unless required by applicable law or agreed to in writing, software
-
 
11
 *   distributed under the License is distributed on an "AS IS" BASIS,
-
 
12
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-
 
13
 *   See the License for the specific language governing permissions and
-
 
14
 *   limitations under the License.
-
 
15
 */
-
 
16
 
-
 
17
package net.brutex.xservices.util;
-
 
18
 
-
 
19
import java.io.File;
-
 
20
 
-
 
21
 
-
 
22
import org.apache.commons.configuration.Configuration;
-
 
23
import org.apache.commons.configuration.ConfigurationException;
-
 
24
import org.apache.commons.configuration.PropertiesConfiguration;
-
 
25
import org.netbeans.lib.cvsclient.Client;
-
 
26
import org.netbeans.lib.cvsclient.admin.StandardAdminHandler;
-
 
27
import org.netbeans.lib.cvsclient.command.CommandAbortedException;
-
 
28
import org.netbeans.lib.cvsclient.command.GlobalOptions;
-
 
29
import org.netbeans.lib.cvsclient.connection.AuthenticationException;
-
 
30
import org.netbeans.lib.cvsclient.connection.PServerConnection;
-
 
31
 
-
 
32
public class CVSClient {
-
 
33
	private final File configfile;
-
 
34
	private final PServerConnection connection;
-
 
35
	private final CVSRoot root;
-
 
36
	private final GlobalOptions globalOptions;
-
 
37
	
-
 
38
	public final Client client;
-
 
39
	
-
 
40
	public CVSClient(File config) throws CommandAbortedException, AuthenticationException, ConfigurationException {
-
 
41
 
-
 
42
		if (config == null || !config.exists() || config.isDirectory())
-
 
43
			throw new ConfigurationException("Config file not found");
-
 
44
		
-
 
45
		this.configfile = config;
-
 
46
		Configuration configuration = new PropertiesConfiguration(configfile);
-
 
47
 
-
 
48
		String cvsroot = configuration.getString("CVSROOT");
-
 
49
		String workdir = configuration.getString("WORKDIR");
-
 
50
		String password = configuration.getString("PASSWORD");
-
 
51
		
-
 
52
		this.root = new CVSRoot(cvsroot);
-
 
53
		this.globalOptions = new GlobalOptions();
-
 
54
		globalOptions.setCVSRoot(cvsroot);
-
 
55
		
-
 
56
		this.connection = new PServerConnection();
-
 
57
		connection.setUserName(root.user);
-
 
58
		if (password != null) {
-
 
59
			connection.setEncodedPassword(CvsPassword.encode(password));
-
 
60
		} else {
-
 
61
			connection.setEncodedPassword(password);
-
 
62
		}
-
 
63
 
-
 
64
		connection.setHostName(root.host);
-
 
65
		connection.setRepository(root.repository);
-
 
66
		connection.open();
-
 
67
 
-
 
68
		this.client = new Client(connection, new StandardAdminHandler());
-
 
69
		client.setLocalPath(workdir);
-
 
70
}
-
 
71
	/**
-
 
72
	 * @return
-
 
73
	 */
-
 
74
	public File getConfigFile() {
-
 
75
		return this.configfile;
-
 
76
	}
-
 
77
	
-
 
78
	public GlobalOptions getGlobalOptions() {
-
 
79
		return this.globalOptions;
-
 
80
	}
-
 
81
	/**
-
 
82
	 * @return the connection
-
 
83
	 */
-
 
84
	public PServerConnection getConnection() {
-
 
85
		return connection;
-
 
86
	}
-
 
87
	/**
-
 
88
	 * @return the root
-
 
89
	 */
-
 
90
	public CVSRoot getRoot() {
-
 
91
		return root;
-
 
92
	}	
-
 
93
	
-
 
94
}
-
 
95
 
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
/*     */ }
-
 
90
 
-
 
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
 */
-
 
95
 
96
Generated by GNU Enscript 1.6.5.90.
96
Generated by GNU Enscript 1.6.5.90.