Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

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.

0 votes


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
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));

1 vote

Comments

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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938
× 56

Question asked: Jul 20 '11, 10:00 p.m.

Question was seen: 7,574 times

Last updated: Oct 12 '17, 1:17 p.m.

Confirmation Cancel Confirm