It's all about the answers!

Ask a question

[closed] How to get change set's Add file name in API


JaeSung Yang (2145) | asked Jul 20 '11, 10:00 p.m.
edited Oct 12 '17, 1:16 p.m. by David Lafreniere (4.7k7)

hi..

i create file in sandbox.

i want to get created file's name at pendding change.

my code :
for (IChange change : (List<IChange>) changeSet.changes()) {
if (((change.kind() & IChange.ADD) == IChange.ADD)) {
extractChangeInformation(scmService, itemService, deliverData, changeSet, change);

}
}

private void extractChangeInformation(IScmService scm, IRepositoryItemService repo, DeliverOperationData data, IChangeSet cs, IChange change) throws TeamRepositoryException {
comment = cs.getComment();
creator = ((IContributor)repo.fetchItem(cs.getAuthor(), null)).getName();
date = cs.getLastChangeDate().toString();
System.err.println("count =" + count);


IServerSideVersionedContentService contentService = getService(IServerSideVersionedContentService.class);
System.out.println("11111111111");
cfgs = ServiceConfigurationProvider.FACTORY.create(data.getDestWorkspace(), cs.getComponent());
System.out.println("222222222222");
IVersionableHandle afterStateHandle = change.afterState();
System.out.println("333333333333");
afterState = scm.fetchState(afterStateHandle, null, null);
System.out.println("4444444444444");
// IVersionableHandle beforeStateHandle = change.beforeState();
System.out.println("55555555555555");
// beforeState = scm.fetchState(beforeStateHandle, null, null);
System.out.println("66666666666666");
if (afterState instanceof IFileItem) {
// if (beforeState instanceof IFileItem) {
IFileItem file = (IFileItem) afterState;
// String aa=file.getName();
// IFileItem file = (IFileItem) beforeState;
// System.err.println("aaaaaa = " + aa);
reports = scm.configurationDetermineAncestorsInHistory(cfgs, new IVersionableHandle[] {file}, null, null);
System.err.println("aaa = "+getPath(reports));
reports = scm.configurationLocateAncestors(cfgs, new IVersionableHandle[] {file}, null, null);
System.err.println("bbb = " +getPath(reports));
System.err.println("=======================================================");
// reports = scm.configurationFindByName(cfgs, file.getName(), null, null);
// System.err.println(getPath(reports));
//out of range System.err.println("ccc = " +getPath(reports));



System.err.println("flag = " + flag);


allreports = getPath(reports);
System.err.println("allreports " + allreports);
if(flag>0){
flag--;
}
System.err.println(comment);
System.err.println(creator);
System.err.println(date);
System.err.println(Location.itemLocation(cs, getRepositoryURL()).toAbsoluteUri());
// printContents("Before file", (IFileItemHandle) beforeState, ((IFileItem)beforeState).getContent(), contentService);
// printContents("After file", (IFileItemHandle) afterState, ((IFileItem)afterState).getContent(), contentService);

}


}

but return value is space(" ").

let me know how to get change set's Add file name.

thanks.

The question has been closed for the following reason: "Problem is not reproducible or outdated" by daviddl Oct 12 '17, 1:16 p.m.

One answer



permanent link
Michael Valenta (3.7k3) | answered Jul 21 '11, 9:04 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
Has the file been checked in? If not, it will not be contained in a change set. You can get at the changes that have not been checked in using the local change manager. The following snippet shows how you could get the local changes. (Disclaimer: this code is off the top of my head so may not be 100% accurate but should point you in the right direction).


ILocalChangeManager lcm = FileSystemCore.getSharingManager().getLocalChangeManager();

ISharingManager sm = FileSystemCore.getSharingManager();

ILocalChanges[] localChanges = lcm.getPendingChanges(sm.allShares(monitor));

Comments
JaeSung Yang commented Jul 27 '11, 3:13 a.m. | edited Oct 12 '17, 1:15 p.m.

Hi

thank you for reply.

when deliver file in pendig change, execute my code .

so, the file has been checked in.

but return value is space(" ").

thanks.