我在使用org.netbeans.lib.cvsclient api时遇到问题。当我登录CVSROOT时,身份验证工作正常,但不能直接在子目录上进行连接。
在后一种情况下,我有一个身份验证失败错误:
Problemsme AuthenticationException:AuthenticationFailed
以下是详细信息:
org.netbeans.lib.cvsclient.connection.AuthenticationException: 验证失败。来自服务器的响应是:"错误0 / cv"。
唯一的修改是修改String cvsroot = ":pserver:name:password@host.fr:2401/cvsdata/BUS-2010";
String cvsroot = ":pserver:name:password@host.fr:2401/cvsdata/BUS-2010/Tools";
这是我的代码,使用org.netbeans.lib.cvsclient api:
package fr.cnamts.navigo.cvs;
import java.io.File;
import java.io.IOException;
import org.junit.Test;
import org.netbeans.lib.cvsclient.CVSRoot;
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.CommandException;
import org.netbeans.lib.cvsclient.command.GlobalOptions;
import org.netbeans.lib.cvsclient.command.commit.CommitCommand;
import org.netbeans.lib.cvsclient.connection.AuthenticationException;
import org.netbeans.lib.cvsclient.connection.PServerConnection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CvsCommandTest {
private static final Logger LOG = LoggerFactory
.getLogger(CvsCommandTest.class);
private final String cvsroot = ":pserver:name:password@host.fr:2401/cvsdata/BUS-2010";
private final String localPath = "/cvsdata/BUS-2010";
private final File f = new File(
"d:/projets/bus/workspaceJhipster/navigo/src/main/resources/logback.xml");
private final File[] files = new File[1];
@Test
public void test() {
CVSRoot root = CVSRoot.parse(cvsroot);
PServerConnection con = new PServerConnection(root);
// con.setUserName(user);
// con.setEncodedPassword(StandardScrambler.getInstance().scramble(
// password));
GlobalOptions globalOptions = new GlobalOptions();
globalOptions.setCVSRoot(root.toString());
Client client = new Client(con, new StandardAdminHandler());
// this line is important, because otherwise you'll get a
// NullpointerException!
client.setLocalPath(localPath);
files[0] = f;
LOG.info("COMMITING");
CommitCommand commitCmd = new CommitCommand();
commitCmd.setBuilder(null);
commitCmd.setRecursive(true);
for (int i = 0; i < files.length; i++) {
LOG.info("- " + files[i].getAbsolutePath());
}
commitCmd.setFiles(files);
commitCmd.setToRevisionOrBranch("testTag");
try {
client.getConnection().open();
LOG.info("CVS COMMAND: " + commitCmd.getCVSCommand());
boolean success = client.executeCommand(commitCmd, globalOptions);
LOG.info("COMMIT COMPLETED : " + success);
client.getConnection().close();
} catch (CommandAbortedException cae) {
LOG.error("Probleme CommandAbortedException : " + cae.getMessage());
} catch (AuthenticationException ae) {
LOG.error("Probleme AuthenticationException : " + ae.getMessage());
} catch (CommandException ce) {
LOG.error("Probleme CommandException : " + ce.getMessage());
} catch (IOException ioe) {
LOG.error("Probleme IOException : " + ioe.getMessage());
}
}
}
如何使用此API在CVSROOT的子目录中提交文件?