I am working on extending the VSSGET task to read from a .txt file (for
requirements see below)
This is what I have so far -

public class VSSFileGetTask extends Task {

  private String m_FileName;

  // The method executing the task
  public void execute() throws BuildException {
        //Read file in StringBuffer
        StringBuffer sb = null;
        try{
                FileInputStream fis = new FileInputStream(m_FileName);
                sb = new StringBuffer();
                int n;
                while((n = fis.available()) > 0){
                        byte[] b = new byte[n];
                int result = fis.read(b);
                if(result == -1) break;
                sb = sb.append(new String(b));
        }
        } catch(IOException exp) { 
                System.out.println(exp.getMessage());
        }
        //For each line in the .txt file do VSSGET
        StringTokenizer st = new StringTokenizer(sb.toString(),"\r\n"); 
        StringTokenizer st1 = null;
        while (st.hasMoreTokens()) {
                st1 = new StringTokenizer(st.nextToken(),",");
                String file = st1.nextToken();
                String ver = st1.nextToken();
                doVSSGET(file,ver);
        }
  }

  public void doVSSGET(String fileToGet,String version) {
        MSVSSGET vssGet = new MSVSSGET();
        vssGet.setSsdir("\\\\RemoteVSSServer\\Share\\Dir");
        vssGet.setVsspath(fileToGet);
        vssGet.setVersion(version);
        vssGet.setLogin("user,password");
        vssGet.execute();
        }

I get a NullPointerException - 
java.lang.NullPointerException
        at
org.apache.tools.ant.taskdefs.optional.vss.MSVSS.run(MSVSS.java:159)
        at
org.apache.tools.ant.taskdefs.optional.vss.MSVSSGET.execute(MSVSSGET.java:16
7)
        at com.ocs.util.VSSFileGetTask.doVSSGET(VSSFileGetTask.java:58)
        at com.ocs.util.VSSFileGetTask.execute(VSSFileGetTask.java:45)
        at org.apache.tools.ant.Target.execute(Target.java:142)
        at org.apache.tools.ant.Project.runTarget(Project.java:818)
        at org.apache.tools.ant.Project.executeTarget(Project.java:532)
        at org.apache.tools.ant.Project.executeTargets(Project.java:506)
        at org.apache.tools.ant.Main.runBuild(Main.java:420)
        at org.apache.tools.ant.Main.main(Main.java:149)

What am i doing wrong?

- vineet

-----Original Message-----
From: Vineet Bhatia 
Sent: Thursday, January 11, 2001 5:41 PM
To: '[EMAIL PROTECTED]'
Subject: Extending the VSSGET task


I am working on extending the VSSGET task for my organisation. 
The requirements are like this - 

1) We give Ant a .txt file containing a list of file-names and versions to
get from VSS the DEV sourcesafe database.
   This new task should go through the .txt file and invoke VSSGET for each
file-name.

2) Then I need to check-in these files to another VSS sourcesafe database.

My question is how can I make use of the VSSGET class to set the name of the
file to get?
The API has methods like -

 void setDate(java.lang.String date) 
          Set the stored date string  
 void setLabel(java.lang.String label) 
          Set the labeled version to operate on in SourceSafe  
 void setLocalpath(Path localPath) 
          Set the local path. 
 void setRecursive(boolean recursive) 
          Set behaviour recursive or non-recursive 
 void setVersion(java.lang.String version) 
          Set the stored version string  
 void setWritable(boolean argWritable) 
          Set behaviour, used in get command to make files that are 'got'
writable 

I can make use of setVersion(), but, why is'nt there a setFileName(String
fileToGet) method?
Is there any alternate way to do this?

Regards.
Vineet Bhatia

Reply via email to