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! |
2 answers
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. |
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.