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

In the Java Server API, How to list the changed files

Good afternoon,

I'm developing a new "scm" advisor (Server-side) for to check a specific duplicated file extension on Deliver operation.

With API, I've already retrieved change sets, components, streams, baselines etc. But I've not found a way to list the change files (of Change set). Also, I need to list the components' files.

I've found several articles to retrieve files, but only Client-Side advisors.

Does anyone know how to do this?

Thank you!

0 votes



2 answers

Permanent link
you have the change set,  so should be able to find the 'changes' from there..

0 votes

Comments

Hello Sam.

At moment, I have the code below:

while (changeSetIterator.hasNext()) {           
    IChangeSet changeSet = (IChangeSet) changeSetIterator.next();           
    List<IChange> changes = changeSet.changes();           
    for (IChange iChange : changes) {              
        IVersionableHandle item = iChange.item();
        ...
    } 
}
The item is my change but How do I get the item name?






The name of the file/folder is on the full IVersionable object. You can fetch this by calling: VersionableManager$fetchCompleteStates(...)


Permanent link
Pietro,
this code I wrote retrieves the paths of files contained in a change set:

.........
IChange change = (IChange)changesIterator.next();
IVersionableHandle changeObj = null;
Integer changeKind = change.kind();
switch (changeKind) {
case 1: {
    // added
    addedElement = true;
    changeObj = change.afterState();
    };
break;
case 2: {
    // modified
    modifiedElement = true;
    changeObj = change.afterState();
};
break;
case 16: {
    // removed
    deletedElement = true;
    changeObj = change.beforeState();
};
default: {
};
break;
}
// element path, starting from the component root
String elementPath = "";
ServiceConfigurationProvider configProvider = ServiceConfigurationProvider.FACTORY.create(findStreamFromEnvironment(deliveryTargetName, repositoryProgressMonitorHandle), changeSet.getComponent());
List<?> nameItemPairs = null;                                           
if (modifiedElement) {
    IAncestorReport reports[] = scmService.configurationLocateAncestors(configProvider, new IVersionableHandle[] {changeObj}, null, repositoryProgressMonitorHandle);
    nameItemPairs = reports[0].getNameItemPairs();
}   
if (addedElement) {
    IAncestorReport reports[] = scmService.configurationLocateAncestors(configProvider, new IVersionableHandle[] {changeObj}, null, repositoryProgressMonitorHandle);
    nameItemPairs = reports[0].getNameItemPairs();                       
}           
if (deletedElement) {
    IAncestorReport reports[] = scmService.configurationDetermineAncestorsInHistory(configProvider, new IVersionableHandle[] {changeObj}, null, repositoryProgressMonitorHandle);
    nameItemPairs = reports[0].getNameItemPairs();
}           
if (nameItemPairs.isEmpty()) {
    IAncestorReport reports[] = scmService.configurationDetermineAncestorsInHistory(configProvider, new IVersionableHandle[] {changeObj}, null, repositoryProgressMonitorHandle);
    nameItemPairs = reports[0].getNameItemPairs();
}                   
for (Iterator<?> iterator = nameItemPairs.iterator(); iterator.hasNext();) {
    INameItemPair nameItemPair = (INameItemPair)iterator.next();
    String pathPiece = nameItemPair.getName();
    if (pathPiece != null) {
        elementPath = elementPath.concat("/" + pathPiece);
    }
}
if (elementPath.isEmpty()) {
    elementPath = "<element removed by another change set>";
}


I hope it helps you.

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

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
× 1,202
× 169
× 27
× 17

Question asked: Jul 26 '16, 1:41 p.m.

Question was seen: 3,981 times

Last updated: Jul 31 '16, 12:08 p.m.

Confirmation Cancel Confirm