cancel
Showing results for 
Search instead for 
Did you mean: 

Document hit count never stops..

Former Member
0 Kudos

Hi All

I followed the steps as described in [this|https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/2654] blog to count the number of document hits.

The problem is that after clicking on the document for the first time, the count is incremented (as expected); however it keeps on incrementing from there on each second even without clicking the document again.

Please help me to solve this problem.

Thanks

Deepak

Accepted Solutions (1)

Accepted Solutions (1)

former_member188556
Active Contributor
0 Kudos

Is this document part of an index?

Check that... if its indexed i have an answer why it happens...

Regards

BP

Former Member
0 Kudos

Hi BP

Thanks for the reply.

Yes. All the documents in that repository are part of an index service.Request you to please explain as to why this counting problem occurs.

AIso, request you to please let me know about the other alternatives.

Thanks

Deepak

former_member188556
Active Contributor
0 Kudos

Deepak,

As the docs r part of an index, when you acces the doc,

1->ur repo service will be called to update the hit count prop.

2->as the property got updated, the index service will be called and will access(read) the doc.

3->then again ur repo service is called to update the hit count

this will go on ...

so u can avoid this countless looping,

1-> remove the doc from index

2-> or in the service, check for the user who inviked the resource.get event.

it should not be index_service user.

Regards

BP

Former Member
0 Kudos

Hi BP

Yes, I understand the problem now. Thanks for the hint. Awarded points.

I cannot deindex the repository. It's required.

As per the blog, there is no explicit call to the index service user. (Please correct me if am wrong). It would be great if you can let me know as to where in the code, I can add an explicit user and make this user call the get event.

Currently,

mgr.getEventBroker().register(this, ResourceEvent.GET_TEMPLATE);

is called in the addRepositoryAssignment(IRepositoryManager mgr) method.

Please suggest where to make the changes. Also, is there any way, where i can run services like index or cmadmin and still ensure that the "Modified By" field reflects the name of the user who had modified the doc recently instead of these km services..??

Thanks

Deepak

former_member188556
Active Contributor
0 Kudos

Deepak,

public void received(IEvent event) {
		IResourceEvent myEvent = (IResourceEvent) event;
		IResource reso = myEvent.getResource();
		IResourceContext rctxt = reso.getContext();
		logger.fatalT("User:::" + rctxt.getUser().getDisplayName());

In the above method,


if (rctxt.getUser().getDisplayName().equalsIgnoreCase("index_service")
			== false) {

use it, so that index_service user access wont update the property.

Just see the loggers, to check whose is the rctxt.getUser(), when the user acess the document.

if it is the logged in user, then u can use the same user context to modify(update) the property.

Give a try on that point.

Regards

BP

Former Member
0 Kudos

Hi BP

Thanks again for the code.

I had changed the user of the resource context to cmadmin_service and it's still the same problem.



IResourceEvent myEvent = (IResourceEvent) event; 
IResource res = myEvent.getResource();
try {
      com.sapportals.portal.security.usermanagement.IUser serviceUser;
      serviceUser =WPUMFactory.getUserFactory().getUser("cmadmin_service");
      IResourceContext rctxt = res.getContext();
      rctxt.setUser(serviceUser);
} catch (UserManagementException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
				

Though, IUser is deprecated, just used it to test the user change logic. After deploying, the "Modified By" field of the document now reflects "cmadmin_service" after clicking the doc. However, the problem still persists.

As per the logic described by you, if there's any change in the property metadata, index service calls the associated documented for indexing which in turn calls the repository service... n goes on....

So even if I change the user, the property metadata (hitcount) will however be changed and this is triggering the loop again.

Hence, in this case, I should update a property which does not call the index service. Does Application Property solves this issue or something else...??

former_member188556
Active Contributor
0 Kudos

Hi Deepak,

		
public void received(IEvent event){

IResourceEvent myEvent = (IResourceEvent) event;
		IResource reso = myEvent.getResource();
		IResourceContext rctxt = reso.getContext();
		logger.fatalT("User:::" + rctxt.getUser().getDisplayName());
		RID resoRid = null;

		if (rctxt.getUser().getDisplayName().equalsIgnoreCase("index_service")
			== false) {

		              logger.fatalT(
			"Res:::"
				+ reso.getDisplayName()
				+ " .Event is::: "
				+ event.getDescription());
		               try {
			//Do your logic here....
                                                //

			} catch (NotSupportedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (AccessDeniedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (ResourceException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (NumberFormatException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			

		}//end of IF loop
}

the if loop will avoid the "index_service" user getting into the loop and hence the property wont be updated.

and hence property is not updated, the rep service wont be called up again..

Regards

BP

Former Member
0 Kudos

Hi BP

Thanks for the code and it's explanation.... It worked...!!!

This time, the "Modified By" fields reflects the name of the user who has logged in and the hit count is updated only if a document is clicked and not otherwise.

Once again, thank you.... Awarded full points....

Thanks

Deepak

Answers (0)