I found the solution of "hasLocalFileChanged" by using
SourceVersionChecker checker = new
SourceVersionChecker(dir,archurl,archname);
StoredFileInfoBean bean=checker.getStoredFileInfo(info.getNodeName());
long localid=bean.getSourceVersionUniqueID();
and
long
serverid=CommandCentral.getInstance().getFileLatestVersionID(info.getUniqueID());
This tells me if the server version is newer. So I still need to call hasLocalFileChanged to know if
the local version is newer.
You'll find enclosed a little class called jammerlist that creates a file
out.txt
java jammerlist c:\your_jammerclient_directory\conf %1 %2 %3 %4
%1=login, %2=pass, %3=function, %4=archive
%3 =
S = all files different on server
O = all files checked out
W = all files with something
A = all files
You'll find a screen shot of the result
I wrote the url directly in the code, but you may easily add a new argument. Sorry I wrote also the
path separator as "\" because i'm on windows.. I'll change that later.
Next step is to restrict search to a certain directory only to avoid full
search. I'll do that later.
My suggestion to the dev team is that these lists could be added near the menu "folder/view
check-out report" in client gui, because the built-in checkout report is really not enough.
Thanks for your help.
Albert Moliner wrote:
Oh, now I've remembered that probably the way to know whether someone had
checked a file in is to get the server's version number and compare it with the
local one. What I ignore is whether that can be checked manually or there's a
call that automates it.
Albert.
----- Original Message -----
From: "Riccardo Cohen" <[EMAIL PROTECTED]>
To: <sourcejammer-users@lists.sourceforge.net>
Sent: Monday, August 08, 2005 9:43 AM
Subject: [SourceJammer-users] [Fwd: Re: using SimpleInterface to connect]
Any idea for my pb on hasLocalFileChanged ?
Thanks
-------- Original Message --------
Subject: Re: using SimpleInterface to connect
Date: Fri, 29 Jul 2005 17:26:50 +0200
From: Riccardo Cohen <[EMAIL PROTECTED]>
Organization: articque
To: sourcejammer-users@lists.sourceforge.net
References: <[EMAIL PROTECTED]>
[...]
So now I can call the function hasLocalFileChanged(). But unfortunately it
does not do all what I
want : It answers "true" when the file have been locally modified but "false"
when the server file
have been checked-in by someone else.
I don't see why SourceVersionChecker.isStoredFileInfoAccurate() (called in
hasLocalFileChanged) does
not detect that the server version is not the same as mine in that case ?
I'll be in holidays next week and see that after.
Thanks for all your help
--
Riccardo Cohen
Articque
Les Roches
37230 Fondettes
France
web = http://www.articque.com
tel: +33 02 47 49 90 49
fax: +33 02 47 49 91 49
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
SourceJammer-users mailing list
SourceJammer-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sourcejammer-users
--
Riccardo Cohen
Articque
Les Roches
37230 Fondettes
France
web = http://www.articque.com
tel: +33 02 47 49 90 49
fax: +33 02 47 49 91 49
import java.lang.*;
import java.util.*;
import java.sql.*;
import java.io.*;
import java.net.*;
import org.sourcejammer.client.*;
import org.sourcejammer.client.filesys.*;
import org.sourcejammer.client.plugin.*;
import org.sourcejammer.client.gui.*;
import org.sourcejammer.client.gui.conf.*;
import org.sourcejammer.client.simpletools.*;
import org.sourcejammer.project.*;
import org.sourcejammer.project.view.*;
import org.sourcejammer.util.*;
import org.sourcejammer.xml.*;
import org.w3c.dom.*;
public class jammerlist
{
public static SimpleInterface si;
public static String function,localarchive;
public static String archname,archurl;
public static FileOutputStream st;
static
{
si=null;
function="";
st=null;
localarchive="";
archname="";
archurl="http://jam.articque.com/servlet/rpcrouter";
}
public static void main(String[] args)
{
if (args.length!=5 || args[3].length()!=1)
{
System.out.println("syntax : jammerlist c:\\jammer\\conf login password function archive");
System.out.println("function=");
System.out.println(" S = all files different on server");
System.out.println(" O = all files checked out");
System.out.println(" W = all files with something (=S+O)");
System.out.println(" A = all files");
return;
}
boolean fail=false;
Project proj=null;
Document doc=null;
String archivconf="";
String archivlocal="";
// static
si=SimpleInterface.getInstance();
function=args[3];
archname=args[4];
//
try{st=new FileOutputStream("out.txt");}catch(Exception ex){fail=true;}
if (fail)
System.out.println("cannot write file");
if (!fail)
{
fail=(jammerlist.si==null);
if (fail)
System.out.println("si null");
}
if (!fail)
{
jammerlist.si.setOut(System.out);
try{jammerlist.si.setConfDirectory(args[0]);}catch(Exception ex){fail=true;}
if (fail)
System.out.println("conf err");
}
if (!fail)
{
try{proj=jammerlist.si.connect(args[4],archurl,
args[1],args[2]);}catch(Exception ex){ex.printStackTrace();fail=true;}
if (fail)
System.out.println("connect err");
}
if (!fail)
{
fail=proj==null;
if (fail)
System.out.println("proj null");
}
if (!fail)
{
AppConfig apconf=AppConfig.getInstance();
archivconf=apconf.getConfigFilePath()+"\\"+args[4]+"."+args[1];
//System.out.println("conf="+archivconf);
try{doc=XMLUtil.getXMLDoc(new java.io.File(archivconf));}catch(Exception ex){doc=null;}
fail=doc==null;
if (fail)
System.out.println("fail parsing conf:"+archivconf);
}
if (!fail)
{
Element archdef=null,archelem=null;
StringBuffer buf=new StringBuffer();
if (!fail)
{
try{archdef=XMLUtil.getChildElement("DefaultDirectories",doc.getDocumentElement());
}catch(Exception ex){System.out.println("no defdir");fail=true;}
if (!fail)
fail=archdef==null;
}
if (!fail)
{
try{archelem=XMLUtil.getChildElement(args[4],archdef);
}catch(Exception ex){System.out.println("no archname");fail=true;}
if (!fail)
fail=archelem==null;
}
if (!fail)
{
buf=XMLUtil.getTextFromNode(archelem,"!");
fail=buf==null;
}
if (!fail)
localarchive=buf.toString();
if (fail)
System.out.println("cannot find defdir in xml:"+archivconf);
}
if (!fail)
{
/*
try{java.io.File file=CommandCentral.getInstance().getGuiConf().getDefaultWorkingDirectory();
System.out.println("Local archive at "+file.getAbsolutePath());
}catch(Exception ex){ex.printStackTrace();}
*/
// misc infos
System.out.println("\n\nUser="+args[1]+"\nArchive="+args[4]+"\nFunction="+function);
try{ArchiveProperties prop=CommandCentral.getInstance().getArchiveProperties();
System.out.println("Remote archive at "+prop.getArchiveRoot());
}catch(Exception ex){}
System.out.println("Local archive at "+localarchive);
// run
System.out.println("\n\n");
System.out.println("different\tcheckedout\tfile");
try{st.write("different(L/S)\tcheckedout\tfile\twarning\n".getBytes());}catch(Exception ex){}
check_proj(proj,0,"");
System.out.println("\n\n");
}
if (!fail)
{
try{jammerlist.si.disconnect();}catch(Exception ex){fail=true;}
if (fail)
System.out.println("disconnect err");
}
try{st.close();}catch(Exception ex){}
System.out.println(fail?"failed":"ok");
}
public static void check_proj(Project proj,int level,String curpath)
{
level++;
NodeIterator itr = proj.childNodes();
while (itr.hasMoreNodes())
{
NodeInfo info=(NodeInfo)itr.getNextNode();
if (info.getNodeType()==AppConfig.NodeTypes.PROJECT)
{
long id=info.getUniqueID();
Project subp;
try{subp=jammerlist.si.getProjectObj(id);}catch(Exception ex){subp=null;}
if (subp!=null)
{
//System.out.println(get_level(level)+"<"+subp.getNodeName()+">"+" (in "+localarchive+"\\"+curpath+")");
check_proj(subp,level,curpath+subp.getNodeName()+"\\");
}
}
else if (info.getNodeType()==AppConfig.NodeTypes.FILE)
{
//System.out.println(get_level(level)+info.getNodeName()+" (in "+localarchive+"\\"+curpath+") ");
String chk="",chg="";
// checkout
if (info.isCheckedOut())
{
String user=info.getCheckedOutToUser();
if (user!=null)
chk=user;
}
// changed
String fulldir=localarchive+"\\"+curpath;
chg=file_changed(info,new java.io.File(fulldir));
if (
(chk.length()>0 && (function.equals("O") || function.equals("W"))) ||
(chg.equals("S") && function.equals("S")) ||
(chg.length()>0 && function.equals("W")) ||
function.equals("A")
)
{
String warning="";
if (chk.length()==0 && chg.equals("L"))
warning="!";
System.out.println(chg+"\t"+chk+"\t"+curpath+info.getNodeName()+"\t"+warning);
try{st.write((chg+"\t"+chk+"\t"+curpath+info.getNodeName()+"\t"+warning+"\n").getBytes());}catch(Exception ex){}
}
}
}
}
public static String get_level(int lev)
{
String ret="";
int idx;
for (idx=1;idx<=lev;idx++)
ret+=" ";
return(ret);
}
public static String file_changed(NodeInfo info, java.io.File dir)
{
String ret = "";
java.io.File fl = new java.io.File(dir, info.getNodeName());
if (fl.exists())
{
try
{
boolean changed=false;
try{changed=CommandCentral.getInstance().hasLocalFileChanged(
info.getNodeName(),dir);}catch(Exception ex){}
if (changed)
ret="L";//this is a file modified locally (it is checked out)
SourceVersionChecker checker = new SourceVersionChecker(dir,archurl,archname);
StoredFileInfoBean bean=checker.getStoredFileInfo(info.getNodeName());
long localid=bean.getSourceVersionUniqueID();
long serverid=CommandCentral.getInstance().getFileLatestVersionID(info.getUniqueID());
//System.out.println(""+localid+" / "+serverid);
if (localid!=serverid)
ret+="S";//this is a file newer on the server (checked in by someone else)
}catch(Exception ex){}
}
return ret;
}
}
/*
SJRequest request = CommandCentral.getInstance().getBaseRequest();
request.putLong(SJRequestParams.REQUESTED_NODE_UNIQUE_ID, info.getUniqueID());
request.putInt(SJRequestParams.VERSION_NUMBER, 0);
request.putInt(SJRequestParams.REQUESTED_EOL_TYPE, AppConfig.getInstance().getDefaultEOLType());
SourceJammerClient.getInstance().getFileListeners().
notifyFileVersionGet(request, null, EventTimingType.BEFORE_REQUEST_SENT, info);
SJResponse response = CommandCentral.getInstance().sendRequest(
request, SOAPPortal.MCPMethodNames.GET_FILE_VERSION);
SourceJammerClient.getInstance().getFileListeners().
notifyFileVersionGet(request, null, EventTimingType.AFTER_RESPONSE_RECEIVED, info);
System.out.print("file="+info.getNodeName()+" vers="+info.getNumVersions()); //ALWAYS -1 !!
*/