Jump to content


p4java getExtendedFiles with a client name vs depot path

p4java fstat

  • Please log in to reply
2 replies to this topic

#1 guinyardlives

guinyardlives

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 21 August 2014 - 06:42 PM

I have a web service running on 2013.2 that searches for files by depot path as follows:
- create an IServer, login as my.user supplying the password
- create a single-entry list of IFileSpec's with FileSpecBuilder.makeFileSpecList("//depot/project/stream/...");
- call IServer.getExtendedFiles(fileSpecList, -1, sinceChangelist, -1, null, null);

and it seems to work fine.  The web service is not running 'within' the workspace, or even on a box with any workspaces.  But I need to change it so that I'm searching by workspace/client name instead of depot path, and I'm just not seeing how to get it to work.  

I've tried:
- create a single-entry list of IFileSpec's with FileSpecBuilder.makeFileSpecList("//my.user_project-wksp/...");
isn't right, it just comes back with:
  ERROR: //my.user_project-wksp/... - must refer to client 'noclient'.
- manually create an ExtendedFileSpec with FileSpecOpStatus.VALID, and setClientName("my.user_project-wksp"); and setClientPath("//my.user_project-wksp/..."); and all sort of combinations thereof, it just errors out with the "must refer to client 'noclient'" message
- manually create an ExtendedFileSpec with FileSpecOpStatus.VALID, and setClient(IServer.getClient("my.user_project-wksp")), but that complains that fstat has missing/wrong number of arguments.

So, is there a way to do this from the p4java api?  The docs make it sound like it should work with either a depot path or a client name, and it works fine with the depot path.  

Many thanks...

#2 Tubah

Tubah

    Advanced Member

  • Staff
  • 45 posts

Posted 21 August 2014 - 08:04 PM

Your server instance's currentClient is not set - you need to set that before you can use it for a filespec.

Code snippet:

    server = ServerFactory.getServer(serverUrl, getProperties());
    server.setUserName(username);
    server.connect();

    server.login(password);

    IClient client = server.getClient(clientName);
    server.setCurrentClient(client);


    List<IFileSpec> files = FileSpecBuilder.makeFileSpecList("//" + clientName + "/...") ;
    List<IExtendedFileSpec> efiles = server.getExtendedFiles(files, -1, sinceChangelist, -1, null, null) ;


#3 guinyardlives

guinyardlives

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 21 August 2014 - 09:53 PM

That was it, muchas gracias!  I guess I was thrown off a little by the searching-by-depot-path working without having set the client, so I was looking straight past it.  Now I know!





Also tagged with one or more of these keywords: p4java, fstat

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users