Is it possible to find items shared into another project?

0 Likes

Problem:

Is it possible to find items shared into another project?

Resolution:


  • Product Name: StarTeam
  • Product Version: 2008 SDK
  • Product Component: Custom
  • Platform/OS Version: All


This can be achieved using the SDK. The following code can be used to search through the Item References and locate items shared to another project.



private void refSearch(Items allItems) {
for ( int i = 0; i
Item item = allItems.getAt(i);
ItemReference[] itemRef;
itemRef = item.getReferences();
for ( int j = 0; j
ItemReference iR = itemRef;
if ( iR.getProjectID() != currentView.getProject().getID()) {
if ( j == 0 ) {
System.out.println("Item [" iR.getItemID() "] shared
from different project.");
break; // break here since the other
// references won"t concern us.
} else {
System.out.println("Item [" iR.getItemID() "] shared to
a different project!");
}
}
}
}
}

private void itemSearch() {
ArrayList alTypes = new ArrayList();
alTypes.add(currentView.getTypeNames().FOLDER);
alTypes.add(currentView.getTypeNames().FILE);

FolderListManager flm = new FolderListManager( currentView );
flm.includeFolders(currentView.getRootFolder(), -1);

Iterator alIter = alTypes.iterator();
while (alIter.hasNext()) {
Type t = currentView.getServer().typeForName(alIter.next());
ItemListManager ilm = new ItemListManager( t, flm );
Items allItems = ilm.getItems();
refSearch( allItems );
}
}

The "refSearch" method uses the generic item class, so it will have to be cast before you can call other methods that will get the descriptive names. Also, be advised that this code is searching everything (using the "includeFolders" method), so it may take some time to run.


Old KB# 29917
Comment List
Related
Recommended