It's all about the answers!

Ask a question

Java API: setting workspace visibility to project area scope

Oscar Picasso (311420) | asked Jan 21 '14, 10:22 a.m.

What is the proper way, with the java API 4.0.3, to set the visibility of a repository workspace to scoped to a particular project area.

I tried something like the code below, with different combinations of parameters including with IScmService.NOOP_OWNER or IScmService.DEFAULT_VISIBILITY but it fails with different exceptions like "Invalid scope for Contributor owner", "Workspace may only have contributor owners" etc.

IWorkspaceConnection targetFlow = ...;
IWorkspaceConnection workspace = workspaceManager
.createWorkspace(repo.loggedInContributor(), "workspace name",
"description", targetFlow, targetFlow,
IProcessAreaHandle area = targetFlow
ProcessAreaScope scope = (ProcessAreaScope) IReadScope.FACTORY

Accepted answer

permanent link
Tim Mok (6.6k38) | answered Jan 21 '14, 11:07 a.m.
Using IScmService.NOOP_OWNER is correct since you don't want to change the owner. If you do change the owner, it must be a contributor for your repository workspace.

For the visibility, you want to change the scope to a project area so don't use the IScmService.DEFAULT_VISIBILITY. To define a new scope, use IReadScope.FACTORY.createContributorDeferringScope() to get an instance of a new scope. Then set the scope on it to your project area. This scope instance is what you pass in for the IWorkspaceConnection.setOwnerAndVisibility(...) call.
Oscar Picasso selected this answer as the correct answer

Your answer

Register or 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.