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.
 Hi,

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,
NULL_PROGRESS_MONITOR);
IProcessAreaHandle area = targetFlow
.getProcessArea(NULL_PROGRESS_MONITOR);
ProcessAreaScope scope = (ProcessAreaScope) IReadScope.FACTORY
        .createProcessAreaScope();
scope.setProcessArea(area);
workspace.setOwnerAndVisibility(?,
?, NULL_PROGRESS_MONITOR);


Accepted answer


permanent link
Tim Mok (6.6k38) | answered Jan 21 '14, 11:07 a.m.
JAZZ DEVELOPER
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.