cancel
Showing results for 
Search instead for 
Did you mean: 

How to run a scheduler task with a service user?

Former Member
0 Kudos

Hi all,

I have a scheduler task that read KM documents in order to count the number of hitcounts (hitcounts service).

Ther scheduler run with <b>Guest </b> user that hasn't right to read the hitcount property. How can I specify in the application that the job has to run with a service user like administrator?

I think the problem is here:

try {

IWDClientUser wdClientUser = WDClientUser.getCurrentUser();

com.sap.security.api.IUser sapUser = wdClientUser.getSAPUser();

try {

// create ep5 user from current user

IUser ep5User =WPUMFactory.getUserFactory().getEP5User(sapUser);

// get the principal context

IResourceContext context = new ResourceContext(ep5User);

IResourceFactory factory = ResourceFactory.getInstance(); // Get the RID of old document

.............

Thanks a lot,

Vito

Accepted Solutions (0)

Answers (1)

Answers (1)

detlev_beutner
Active Contributor
0 Kudos

Hi Vito,

Please clarify different things:

> a scheduler task that read KM documents in order

> to count the number of hitcounts

You want to count periodically the hits? (Which are written by a repository service, probably?!)

> IWDClientUser

-- why are we talking about WebDynpro? If you are talking about scheduler tasks, I expect you are talking of a KM scheduler task which is not running as a WD application but as a portal application!?!

How to use a ServiceUser is simple anyhow:

IUser user = WPUMFactory.getServiceUserFactory().getServiceUser("cmadmin_service"); // or whichever service user one needs...

Hope it helps

Detlev

Former Member
0 Kudos

Hi Detlev,

this solve my problem, but just another BIG question.

My scheduler task read the porperty hitcount and just after set 0.

The problem is that in the "Modified By" field on KM, for each field I see the user "cmadmin_service" and also the date the Schehuler sets the property...this is really not good if the user see this!!! How can I hidden this?

Thanks a lot,

Vito

detlev_beutner
Active Contributor
0 Kudos

Hi Vito,

As long as you use "normal" properties for such a purpose, changing the property just means changing the resource, and therefore the modifier and the modification date will get changed, too. This is by design.

The solution is not to use resource properties but application properties. These are maintained independent from the resource itself and therefore changing these properties does not mean changing the resource.

Also see /thread/310690 [original link is broken] and the links referred to there.

Hope it helps

Detlev

Former Member
0 Kudos

Hi Detlev,

could you please send me a smart link where explained how to create an application property? The link you sent me open a post where the links are wrong.

Thanks,

Vito

detlev_beutner
Active Contributor
0 Kudos

Hi Vito,

The thread itself offers the info within the last code fragment by shi zi; also the link to the weblog works perfectly, too. For the API, also see http://help.sap.com/javadocs/NW04/current/km/com/sapportals/wcm/repository/service/appproperties/IAp...

Hope it helps

Detlev

Former Member
0 Kudos

Hi Detlev,

I am also trying to create repository service as well as global service. I have tried the hitscount weblog, its not working for me. If you have document or code samples please send to my mail id (kvee20980@yahoo.co.in) or paste the links here.

Thanks in advance.

With Regards,

Venkatesh.K

Former Member
0 Kudos

Hi Detlev,

please excuse me for taking so long to answer but I have been very busy.

Finally I used a different solution to avoid the "set metadata" problem on the KM documents without the use of Application Property as you suggested.

As you know the problem was that when the application (may be a Scheduler Task) tried to set the document metadata properties, it modified the "data", "time" and "last user" for the that document.

I solved the problem using a metadata property that keeps information about the total hitcount on the document, <u>no one set the metadata Property</u>.

Then my application (may be Scheduler Task) read the total hitCount and subtract it from the sum of pervious totalhitcounts in each period the application have run (and have read). Then store the value into a DB table. In this table are stored each times two information: the total hitcount and the hitcount from the last reading.

In this way I have the total knowledge of the situation in each period from a statistical point of view. It works cool

Hope all is clear. In any case.. thanks a lot.

Vito Palasciano