com.ibm.team.scm.common.ComponentNotInWorkspaceException
com.ibm.team.scm.common.ComponentNotInWorkspaceException
Accepted answer
A ComponentNotInWorkspaceException usually is a case where the component you are trying to perform operations against (ex: check-in to, or deliver to) does not exist in the repository workspace (or stream) that you are trying to work against.
Ex:
-The other possibility is you are also geting the wrong repository workspace (one that also doesn't have the component) (again, it's normally recommended to use the workspace itemId (UUID) to ensure you are working against the same repo workspace).
-Your snippets do now show how you are getting the repository workspace, or the component, so it's hard to give suggestions around this.
-You should also give a snippet of the stack trace error, as it might help narrow down where the issue is happening (devs might be able to provide insight around this)
Comments
Thank you for the advice. Thank you very much.
IWorkspaceManager wm = SCMPlatform.getWorkspaceManager(teamRepository);
private static IWorkspaceConnection findConnection(String streamName, IProgressMonitor monitor, IWorkspaceManager wm, int kind) throws TeamRepositoryException {
Few comments.
It looks like your code is fetching every single component in the repository (this seems like a lot of unnecessary work, and would likely result in a performance hit if this were ran often enough (ex: Not sure if you run the same code for all file check-ins)
2) You are using deprecated API. IWorkspaceConnection.findAllComponentNames() is deprecated, and will simply give you the names of 4 thousand (but not more) components in the repo.
3) Then for each of those (potentially 4 thousand component) you are creating individual component search queries using the name. Again, if more than one component has the same name, you will run into the case where you likely won't know which want you want.
4) ...I'm past the character limit... so I will post the rest in a new comment....
4) "IF" you really need all component handles for all components in the repo, you could avoid the first fetch of getting all component names, and also making 'x' number of component search criteria requests. Try just doing a single component search criteria... try either not specifying any filters (such as name), or try setting "" for I
5) Likewise for fetching the WorkspaceConnection. This also would not work if there are more than one repository workspaces or streams with the same name.
Here is some sample code of how you can get a componentHandle and workspaceConnection if you just use the itemIds..
... out of character limit again, this will follow in the next comment...
String workspaceItemIdString = "_g4a2I37zEeqR6peqpx3x5w";
Comments
Kodac Hasubo
Mar 06 '22, 8:39 p.m.