It's all about the answers!

Ask a question

PermissionException when using RepositoryItemService


Qiong Feng Huang (76911610) | asked Feb 16 '09, 8:12 a.m.
JAZZ DEVELOPER
We put some initialization logic in method "activate()" of a service. And some specific repository items should be created in the initialization logic. But if we start RTC and create a connection using ADMIN account, PermisssionException will be thrown from RepositoryItemService.saveInCtx(). To solve this problem, we have to use TeamServiceContext to set the curent contributor as Contributor.ADMIN. But the TeamServiceContext is discouraged to use. So, my question is how to solve the permission exception issue without using TeamServiceContext?

One answer



permanent link
Matt Lavin (2.7k2) | answered Feb 16 '09, 8:28 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
The short answer is "don't modify the repository in activate()". That
is the best answer and the only real solution to your problem. As you
point out, TeamServiceContext should not be used, and will likely be
removed or renamed in 2.0 (since it has been deprecated since 1.0).

The reason that activate() is not a good place to execute DB
modification is that it slows down the start up the server, and doesn't
provide the user with good feedback (or failure reporting). If
something fails in your activate() the failure will go to the server log
and will be hard for the user to diagnose. A better option is to
execute the modifications in the context of a user operation so that
errors can be reported back to the user in a nice way.

-
Matt Lavin
Jazz Server Team


On Mon, 2009-02-16 at 13:18 +0000, huangqf wrote:
We put some initialization logic in method "activate()" of a
service. And some specific repository items should be created in the
initialization logic. But if we start RTC and create a connection
using ADMIN account, PermisssionException will be thrown from
RepositoryItemService.saveInCtx(). To solve this problem, we have
to use TeamServiceContext to set the curent contributor as
Contributor.ADMIN. But the TeamServiceContext is discouraged to use.
So, my question is how to solve the permission exception issue without
using TeamServiceContext?

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.