Re: Need help with cvsclient API
"Stephen Gross" <[email protected]> Fri, 18 Feb 2005 10:39:35 -0500
| Newsgroups | gmane.comp.java.netbeans.modules.javacvs.devel |
|---|---|
| Message-ID | <00bf01c515d0$0f8f5640$8df51681@sgross> |
>At the bottom of this message is my test app. I am fumbling through the
API, and I may have some irrelevant code, and/or be missing some crucial
code.
>What I am trying to do, up to this point, is to determine if there is a
module of the given name in the CVS repository.
Ok, I hate to tell you this, but it's REALLY hard to get this kind of
meta-information out of CVS. I've been working on the same thing, and in the
end I gave up on it.
There is one clever workaround I know of: You can use the CVS history
command so scan around for entries indicating the existence of this or that
module. It's awkward though.
My solution, in the end, was to separately store that meta information in a
database, and query the database with SOAP.
--Steve
================================
First I check the modules list, which for this sample is empty. This appears
to be working fine.
Next I want to determine if the user has a sandbox, and if not, create one
by checking out the CVSROOT directory from the repository. No joy. The
checkout command instance throws a Command Exception, but the messages are
null.
Are there any pointers or places I could look for guidance? I tried to look
at smartCVS, but it is obfuscated.
Gerald Shapiro
MITRE/CAASD
703-883-5256
703-883-1911 (Fax)
*** Explore Operations Research: The Science of Better
http://www.scienceofbetter.org <blocked::http://www.scienceofbetter.org/>
***
_______________________________________________
Console output:
No modules found
checkout CVSROOT
WARNING TO DEVELOPERS:
Please be warned that attempting to reuse one open connection for more
commands is not supported by cvs servers very well.
You are advised to open a new Connection each time.
If you still want to proceed, please do:
System.setProperty("javacvs.multiple_commands_warning", "false")
That will disable this message.
Command Exception
null
null
Finished executing
____________________________________________________________________________
_____
Program:
import org.netbeans.lib.cvsclient.connection.* ;
import org.netbeans.lib.cvsclient.command.*;
import org.netbeans.lib.cvsclient.command.checkout.*;
import org.netbeans.lib.cvsclient.Client;
import org.netbeans.lib.cvsclient.admin.StandardAdminHandler;
import java.io.*;
public class cvs_interface {
public static void main(String[] args) {
PServerConnection p = isf_connect();
Client client = new Client(p, new StandardAdminHandler());
client.setLocalPath(".");
client.getEventManager().addCVSListener(new BasicListener());
CheckoutCommand co = new CheckoutCommand();
ModuleListBuilder ouput = new ModuleListBuilder(client.getEventManager(),
co);
String [] modules = co.getModules();
try{
p.close();
}
catch (IOException io) {
System.out.println(io.getLocalizedMessage());
System.out.println(io.getMessage());
}
// System.out.println(modules.length);
if (modules.length != 0) {
for (int i=0; i< modules.length; i++) {
System.out.println(modules[i]);
}
} else {
System.out.println("No modules found");
// Check for the existance of a sandbox
String root = null;
BufferedReader r = null;
try {
File f = new File(System.getProperty("user.dir"));
File rootFile = new File(f, "CVS/Root");
if (rootFile.exists())
{
r = new BufferedReader(new FileReader(rootFile));
root = r.readLine();
}
}
catch (IOException e) { }
finally {
try {
if (r != null) r.close();
}
catch (IOException e) {
System.out.println("Could not close cvs root file");
}
}
if (root == null) {
// Create the CVS Directory
co = new CheckoutCommand();
co.setModule("CVSROOT");
p = isf_connect();
client.setConnection(p);
GlobalOptions options = new GlobalOptions();
options.setCVSRoot(":pserver:"+p.getUserName()+"@"+p.getHostName()+ "
"
+ p.getRepository());
System.out.println(co.getCVSCommand()) ;
try {
co.execute(client, client.getEventManager());
}
catch(AuthenticationException a) {
System.out.println("Authentication error");
System.out.println(a.getMessage());
System.out.println(a.getLocalizedMessage());
}
catch(CommandException c) {
System.out.println("Command Exception");
System.out.println(c.getMessage());
System.out.println(c.getLocalizedMessage());
}
}
}
}
public static PServerConnection isf_connect()
{
PServerConnection developer = new PServerConnection();
developer.setHostName("cvs.developer.mitre.org");
developer.setPort(2401);
developer.setRepository("/cvsroot/jeacm-models");
/* Get the user name and password */
developer.setUserName("gshapiro");
Scrambler s = StandardScrambler.getInstance();
String pw = s.scramble("udon'tneedtoknow");
developer.setEncodedPassword(pw);
try {
developer.open();
}
catch(AuthenticationException a) {
System.out.println(a.getMessage());
System.out.println(a.getLocalizedMessage());
}
catch(CommandAbortedException c) {
System.out.println(c.getMessage());
}
return developer;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]