Author: tchemit Date: 2008-05-13 14:15:51 +0000 (Tue, 13 May 2008) New Revision: 655 Modified: trunk/lutinvcs/provider/cvs/src/main/java/org/codelutin/vcs/provider/cvs/CVSConnexion.java trunk/lutinvcs/provider/cvs/src/main/java/org/codelutin/vcs/provider/cvs/CVSHandler.java trunk/lutinvcs/provider/cvs/src/main/java/org/codelutin/vcs/provider/cvs/CVSHelper.java Log: refactor config + introduction factory de config Modified: trunk/lutinvcs/provider/cvs/src/main/java/org/codelutin/vcs/provider/cvs/CVSConnexion.java =================================================================== --- trunk/lutinvcs/provider/cvs/src/main/java/org/codelutin/vcs/provider/cvs/CVSConnexion.java 2008-05-13 14:15:42 UTC (rev 654) +++ trunk/lutinvcs/provider/cvs/src/main/java/org/codelutin/vcs/provider/cvs/CVSConnexion.java 2008-05-13 14:15:51 UTC (rev 655) @@ -16,6 +16,7 @@ import org.codelutin.vcs.VCSConnexionConfig; import org.codelutin.vcs.VCSException; +import org.codelutin.vcs.VCSRootConfig; import org.codelutin.vcs.type.VCSConnectionState; import org.codelutin.vcs.util.AbstractVCSConnexion; import org.netbeans.lib.cvsclient.CVSRoot; @@ -56,7 +57,8 @@ public String getRemoteUrl() { checkInit(); - return (config.isUseSshConnexion() ? ":ext:" : ":pserver:") + config.getUserName() + "@" + config.getHostName() + config.getRemotePath(); + return getURIResolver().resolv(config).toString(); + //return (config.isUseSshConnexion() ? ":ext:" : ":pserver:") + config.getUserName() + "@" + config.getHostName() + config.getRemotePath(); } protected Client getClient() { @@ -70,30 +72,58 @@ // That will disable this message. // d'ou l'initialisation syst�matique de la connexion. + VCSRootConfig rootConfig = getConfig().getRootConfig(); + String hostName = rootConfig.getHost(); - String hostName = getConfig().getHostName(); - // R�pertoire distant du CVS - String repository = getConfig().getRemotePath(); + String repository = rootConfig.getRepository(); - String userName = getConfig().getUserName(); + String userName = getConfig().getLogin(); - Connection connection; - if (getConfig().isUseSshConnexion()) { - throw new RuntimeException(CVSHelper.class + " you can not used a ssh connexion with CVS, use instead SVN configuration"); - // connexion ssh2 - //TODO Make this works - // Localisation de la clef priv�e (pour la connexion ssh2). - //File keyFile = new File(config.getKeyFile()); - // Stockage des cl�s publics pour les hosts ou il y a eu connexion en ssh2 - //String host = config.getHost(); - // Localisation de la clef priv�e (pour la connexion ssh2). - //File keyFile = new File(IsisConfig.getProperties().getProperty( - // IsisConfig.CVS_KEY_FILE)); - // Stockage des cl�s publics pour les hosts ou il y a eu connexion en ssh2 - //String host = IsisConfig.getProperties().getProperty( - // IsisConfig.CVS_HOST); + String cvsrootString; + PServerConnection PServerConnection; + Connection connection = null; + CVSRoot cvsroot; + switch (getConnexionMode()) { + + case ANONYMOUS: + cvsrootString = ":pserver:" + userName + "@" + hostName + repository; + cvsroot = CVSRoot.parse(cvsrootString); + // connexion pserver + PServerConnection = new PServerConnection(cvsroot); + // PServerConnection.setUserName(userName); + // // PServerConnection.setEncodedPassword(encodedPassword); + // PServerConnection.setHostName(hostName); + // PServerConnection.setRepository(repository); + connection = PServerConnection; + break; + case PASSWORD: + cvsrootString = ":pserver:" + userName + "@" + hostName + repository; + cvsroot = CVSRoot.parse(cvsrootString); + // connexion pserver + PServerConnection = new PServerConnection(cvsroot); + // PServerConnection.setUserName(userName); + // // PServerConnection.setEncodedPassword(encodedPassword); + // PServerConnection.setHostName(hostName); + // PServerConnection.setRepository(repository); + connection = PServerConnection; + break; + case SSH: + throw new RuntimeException(CVSHelper.class + " you can not used a ssh connexion with CVS, use instead SVN configuration"); + // connexion ssh2 + //TODO Make this works + // Localisation de la clef priv�e (pour la connexion ssh2). + //File keyFile = new File(config.getKeyFile()); + // Stockage des cl�s publics pour les hosts ou il y a eu connexion en ssh2 + //String host = config.getHost(); + // Localisation de la clef priv�e (pour la connexion ssh2). + //File keyFile = new File(IsisConfig.getProperties().getProperty( + // IsisConfig.CVS_KEY_FILE)); + // Stockage des cl�s publics pour les hosts ou il y a eu connexion en ssh2 + //String host = IsisConfig.getProperties().getProperty( + // IsisConfig.CVS_HOST); + // Ssh2Connexion ssh2Connection = new Ssh2Connexion(); // ssh2Connection.setUserName(userName); // ssh2Connection.setHostName(hostName); @@ -101,17 +131,7 @@ // ssh2Connection.setHost(host); // ssh2Connection.setRepository(repository); // connection = ssh2Connection; - } else { - String cvsrootString = ":pserver:" + userName + "@" + hostName + repository; - CVSRoot cvsroot = CVSRoot.parse(cvsrootString); - // connexion pserver - PServerConnection PServerConnection; - PServerConnection = new PServerConnection(cvsroot); -// PServerConnection.setUserName(userName); -// // PServerConnection.setEncodedPassword(encodedPassword); -// PServerConnection.setHostName(hostName); -// PServerConnection.setRepository(repository); - connection = PServerConnection; +// break; } // Le connexion est ouverte automatiquement � l'�x�cution de la @@ -125,7 +145,8 @@ public GlobalOptions getGlobalOptions() { checkInit(); GlobalOptions result = new GlobalOptions(); - String repository = getConfig().getRemotePath(); + //String repository = getConfig().getRemotePath(); + String repository = getConfig().getRootConfig().getRepository(); result.setCVSRoot(repository); return result; } Modified: trunk/lutinvcs/provider/cvs/src/main/java/org/codelutin/vcs/provider/cvs/CVSHandler.java =================================================================== --- trunk/lutinvcs/provider/cvs/src/main/java/org/codelutin/vcs/provider/cvs/CVSHandler.java 2008-05-13 14:15:42 UTC (rev 654) +++ trunk/lutinvcs/provider/cvs/src/main/java/org/codelutin/vcs/provider/cvs/CVSHandler.java 2008-05-13 14:15:51 UTC (rev 655) @@ -2,8 +2,8 @@ import static org.codelutin.i18n.I18n._; import org.codelutin.util.FileUtil; +import org.codelutin.vcs.VCSException; import org.codelutin.vcs.VCSConnexionConfig; -import org.codelutin.vcs.VCSException; import org.codelutin.vcs.type.VCSState; import org.codelutin.vcs.util.AbstractVCSHandler; import org.netbeans.lib.cvsclient.command.FileInfoContainer; @@ -31,9 +31,9 @@ public void initWorkingCopy() throws VCSException { VCSConnexionConfig config = connexion.getConfig(); - File root = config.getLocalDatabasePath(); + File root = config.getWorkingCopyFile(); - if (!root.exists()) config.getLocalDatabasePath().mkdirs(); + if (!root.exists()) config.getWorkingCopyFile().mkdirs(); //TODO Should checkout root remote directory unrecurse ? //TODO to have vcs configuration file present in local database directory Modified: trunk/lutinvcs/provider/cvs/src/main/java/org/codelutin/vcs/provider/cvs/CVSHelper.java =================================================================== --- trunk/lutinvcs/provider/cvs/src/main/java/org/codelutin/vcs/provider/cvs/CVSHelper.java 2008-05-13 14:15:42 UTC (rev 654) +++ trunk/lutinvcs/provider/cvs/src/main/java/org/codelutin/vcs/provider/cvs/CVSHelper.java 2008-05-13 14:15:51 UTC (rev 655) @@ -89,7 +89,8 @@ * @throws VCSException TODO */ static public CVSCommandResult checkout(CVSConnexion connexion, File destdir, String module) throws VCSException { - String data = connexion.getConfig().getRemoteDatabase(); + String data = connexion.getConfig().getRootConfig().getRepository(); + //String data = connexion.getConfig().getRemoteDatabase(); //TODO Fix bug when module is a multi path one, check there is no //TODO File.separator String sep = File.separator;