on 09-08-2008 10:59 AM
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
Is this document part of an index?
Check that... if its indexed i have an answer why it happens...
Regards
BP
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
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
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...??
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
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.