PermissionException when using RepositoryItemService
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
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:
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?