Subversion Repositories XServices

Compare Revisions

Ignore whitespace Rev 112 → Rev 113

/xservices/trunk/src/java/net/brutex/xservices/util/CVSClient.java
1,94 → 1,94
/*
* Copyright 2012 Brian Rosenberger (Brutex Network)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* */ package net.brutex.xservices.util;
/* */
/* */ import java.io.File;
/* */ import net.brutex.xservices.types.scm.ItemType;
/* */ import net.brutex.xservices.ws.rs.CVSInfoImpl;
/* */ import org.apache.commons.configuration.Configuration;
/* */ import org.apache.commons.configuration.ConfigurationException;
/* */ import org.apache.commons.configuration.PropertiesConfiguration;
/* */ import org.apache.log4j.Logger;
/* */ import org.netbeans.lib.cvsclient.Client;
/* */ import org.netbeans.lib.cvsclient.admin.StandardAdminHandler;
/* */ import org.netbeans.lib.cvsclient.command.CommandAbortedException;
/* */ import org.netbeans.lib.cvsclient.command.GlobalOptions;
/* */ import org.netbeans.lib.cvsclient.connection.AuthenticationException;
/* */ import org.netbeans.lib.cvsclient.connection.PServerConnection;
/* */
/* */ public class CVSClient
/* */ {
/* */ private final File configfile;
/* */ private final PServerConnection connection;
/* */ private final CVSRoot root;
/* */ private final GlobalOptions globalOptions;
/* 41 */ final Logger logger = Logger.getLogger(CVSInfoImpl.class);
/* */ public final Client client;
/* */
/* */ public Client getClient()
/* */ {
/* 49 */ return this.client;
/* */ }
/* */
/* */ public CVSClient(File config) throws CommandAbortedException, AuthenticationException, ConfigurationException {
/* 53 */ System.setProperty("cvsClientLog", "c:/temp/cvs.log");
/* 54 */ if ((config == null) || (!config.exists()) || (config.isDirectory())) {
/* 55 */ throw new ConfigurationException("Config file not found");
/* */ }
/* 57 */ this.configfile = config;
/* 58 */ Configuration configuration = new PropertiesConfiguration(this.configfile);
/* */
/* 60 */ String cvsroot = configuration.getString("CVSROOT");
/* 61 */ String workdir = configuration.getString("WORKDIR");
/* 62 */ String password = configuration.getString("PASSWORD");
/* */
/* 64 */ this.root = new CVSRoot(cvsroot);
/* 65 */ this.globalOptions = new GlobalOptions();
/* 66 */ this.globalOptions.setCVSRoot(cvsroot);
/* */
/* 68 */ this.connection = new PServerConnection();
/* 69 */ this.connection.setUserName(this.root.user);
/* 70 */ if (password != null)
/* 71 */ this.connection.setEncodedPassword(CvsPassword.encode(password));
/* */ else {
/* 73 */ this.connection.setEncodedPassword(password);
/* */ }
/* */
/* 76 */ this.connection.setHostName(this.root.host);
/* 77 */ this.connection.setRepository(this.root.repository);
/* */ try {
/* 79 */ this.connection.open();
/* */ } catch (AuthenticationException ex) {
/* 81 */ this.logger.error(ex.getMessage());
/* */ }
/* */
/* 84 */ this.client = new Client(this.connection, new StandardAdminHandler());
/* 85 */ this.client.setLocalPath(workdir);
/* */ }
/* */
/* */ public File getConfigFile()
/* */ {
/* 91 */ return this.configfile;
/* */ }
/* */
/* */ public GlobalOptions getGlobalOptions() {
/* 95 */ return this.globalOptions;
/* */ }
/* */
/* */ public PServerConnection getConnection()
/* */ {
/* 101 */ return this.connection;
/* */ }
/* */
/* */ public CVSRoot getRoot()
/* */ {
/* 107 */ return this.root;
/* */ }
/* */
/* */ public static String generateID(ItemType item) {
/* 111 */ return "::[" + item.getRemotename() + "]";
/* */ }
/* */ }
 
package net.brutex.xservices.util;
 
import java.io.File;
 
 
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.netbeans.lib.cvsclient.Client;
import org.netbeans.lib.cvsclient.admin.StandardAdminHandler;
import org.netbeans.lib.cvsclient.command.CommandAbortedException;
import org.netbeans.lib.cvsclient.command.GlobalOptions;
import org.netbeans.lib.cvsclient.connection.AuthenticationException;
import org.netbeans.lib.cvsclient.connection.PServerConnection;
 
public class CVSClient {
private final File configfile;
private final PServerConnection connection;
private final CVSRoot root;
private final GlobalOptions globalOptions;
public final Client client;
public CVSClient(File config) throws CommandAbortedException, AuthenticationException, ConfigurationException {
 
if (config == null || !config.exists() || config.isDirectory())
throw new ConfigurationException("Config file not found");
this.configfile = config;
Configuration configuration = new PropertiesConfiguration(configfile);
 
String cvsroot = configuration.getString("CVSROOT");
String workdir = configuration.getString("WORKDIR");
String password = configuration.getString("PASSWORD");
this.root = new CVSRoot(cvsroot);
this.globalOptions = new GlobalOptions();
globalOptions.setCVSRoot(cvsroot);
this.connection = new PServerConnection();
connection.setUserName(root.user);
if (password != null) {
connection.setEncodedPassword(CvsPassword.encode(password));
} else {
connection.setEncodedPassword(password);
}
 
connection.setHostName(root.host);
connection.setRepository(root.repository);
connection.open();
 
this.client = new Client(connection, new StandardAdminHandler());
client.setLocalPath(workdir);
}
/**
* @return
*/
public File getConfigFile() {
return this.configfile;
}
public GlobalOptions getGlobalOptions() {
return this.globalOptions;
}
/**
* @return the connection
*/
public PServerConnection getConnection() {
return connection;
}
/**
* @return the root
*/
public CVSRoot getRoot() {
return root;
}
}
/* Location: C:\Users\brosenberger\Documents\My Box Files\XBridgeNG-download\XServices-20130131 - Kopie\WEB-INF\classes\net.zip
* Qualified Name: net.brutex.xservices.util.CVSClient
* JD-Core Version: 0.6.2
*/