cancel
Showing results for 
Search instead for 
Did you mean: 

KM Report - Document hit/download count

Former Member
0 Kudos

Hi All,

Is there any way(report or other stuff) thorugh which we can track, let us say "a YYY document has been accessed by 75 people in the perio A & B".

How can we use WebTrend server in tracking user's access to KM Documents? Can we include Web Trend java script in some place.

Regards,

Ganga.

Accepted Solutions (1)

Accepted Solutions (1)

former_member188598
Contributor
0 Kudos

Hi,

I read one blog by Damien regarding the same some time back.

This can be done by developing a repository service which counts documents hits.

These are the steps to get this functionality:

Step 1: Creating a custom property: hitscount

Creating a new property is easy in Enterprise Portal.

Go to

System Administration/System configuration/Knowledge Management/Configuration/Content Management/Global Services/Property Metadata/Properties

and create a new property with the following attributes:

Description = Hit Counter

Unique ID = hitscount

Property ID = hitscount

Namespace alias = default

Type = Integer

Group = default

Mandatory = deactivated

Multi-Valued = deactivated

Read Only = activated

Maintainable = activated

Indexable = activated

Default Value = 0

Allowed Values (csv) = empty

Key for Label = hitscount

Meta Data Extension = Not set

Folder Validity Patterns (csv) = empty

Document Validity Patterns (csv) = repository list

Resource Types (csv) = empty

Mime Types (csv) = empty

Default Sorting = Ascending

Label icon = empty

Hidden = deactivated

Dependencies = deactivated

Additional Metadata (csv) = empty

Property Renderer = integer

Virtual = deactivated

Composed of = none selected

Comparator Class = empty

Now, every documents in the repository list will have this new property (upload a new document and look in its details page, inside Miscellaneous tab!).

Step 2: Developing a repository service

Once we have created this new property we need a repository service which control it increasing his value in each document access.

To develop it we have used SAP Netweaver Developer Studio 2.0.12 with Repository Framework 7.1.5.

Substeps are:

? Create a new Portal Application Project

? Create a new Repository Service using whe wizard

Now, you must have three classes in your project structure: IRFServiceWrapper, RFServiceWrapper and one class with the name you gave in creation, in our case: SampleService.

? Fill theKEY attribute inside IRFServiceWrapper. Tipically with a string like "com.mycompany.SampleService".

Copy and paste the following code into SampleService class. You can take a quick look at this code to know what is it doing. We are subscribing to GET_TEMPLATE event.

package com.mycompany;

import java.util.Collection;

import java.util.Iterator;

import com.sapportals.wcm.WcmException;

import com.sapportals.wcm.crt.component.IReconfigurable;

import com.sapportals.wcm.crt.component.StartupException;

import com.sapportals.wcm.crt.configuration.ConfigurationException;

import com.sapportals.wcm.crt.configuration.IConfiguration;

import com.sapportals.wcm.repository.IProperty;

import com.sapportals.wcm.repository.IResource;

import com.sapportals.wcm.repository.Property;

import com.sapportals.wcm.repository.PropertyName;

import com.sapportals.wcm.repository.ResourceException;

import com.sapportals.wcm.repository.manager.IRepositoryManager;

import com.sapportals.wcm.repository.manager.IResourceEvent;

import com.sapportals.wcm.repository.manager.IResourceEventReceiver;

import com.sapportals.wcm.repository.manager.ResourceEvent;

import com.sapportals.wcm.repository.service.AbstractRepositoryService;

import com.sapportals.wcm.repository.service.ServiceNotAvailableException;

import com.sapportals.wcm.util.events.IEvent;

public class SampleService extends AbstractRepositoryService implements IResourceEventReceiver, IReconfigurable {

private static final String TYPE = "com.mycompany.kmservice.SampleService";

private Collection repositoryManagers;

public SampleService() {

super();

}

public String getServiceType() {

return SampleService.TYPE;

}

protected void startUpImpl(Collection repositoryManagers) throws ConfigurationException, StartupException {

this.repositoryManagers = repositoryManagers;

Iterator it = repositoryManagers.iterator();

while (it.hasNext()){

try {

addRepositoryAssignment((IRepositoryManager) it.next());

} catch (ServiceNotAvailableException e) {

e.printStackTrace();

}

}

}

protected void shutDownImpl() {

Iterator it = repositoryManagers.iterator();

while (it.hasNext()){

try {

removeRepositoryAssignment((IRepositoryManager) it.next());

} catch (WcmException e) {

e.printStackTrace();

}

}

}

protected void addRepositoryAssignment(IRepositoryManager mgr) throws ServiceNotAvailableException {

try {

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

} catch (WcmException e) {

e.printStackTrace();

}

}

protected void removeRepositoryAssignment(IRepositoryManager mgr) throws WcmException {

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

}

public void received(IEvent event) {

IResourceEvent myEvent = (IResourceEvent) event;

try {

IResource res = myEvent.getResource();

PropertyName propertyNameHitCount = new PropertyName("http://sapportals.com/xmlns/cm","hitscount");

Property propHitCount = new Property(propertyNameHitCount,new Integer(0));

// We increase hitscount property value

if (res.getProperty(propertyNameHitCount)!=null) {

IProperty oldHitCount = res.getProperty(propertyNameHitCount);

String sOldHitCount = oldHitCount.getValueAsString();

int iOldHitCount = Integer.parseInt(sOldHitCount);

iOldHitCount++;

propHitCount = new Property(propertyNameHitCount,new Integer(iOldHitCount));

res.setProperty(propHitCount);

}

} catch (ResourceException e) {

e.printStackTrace();

}

}

public void reconfigure(IConfiguration arg0) throws ConfigurationException {

}

}

Step 3: Activating the new service

The new service must be activated in those repositories that you want to control.

To do this you can go to

System Administration/System configuration/Knowledge Management/Configuration/Content Management/Repository Managers/CM Repository

and check the repositories to control.

Is important to restart servlet engine.

This is a easy solution to know how many users have read one document in knowledge management.

Also check this thread:

https://www.sdn.sap.com/irj/sdn/thread?threadID=384871

https://www.sdn.sap.com/irj/sdn/thread?threadID=45636

Regards

Priyanka

award point if it helps

sasi_reddy7
Participant
0 Kudos

Hi,

I have implemented the repository service as per above code. I was able to see the property that I have created in portal( EP7.31,SP12), fir all thge documents. But when I deplyed my code, I cant see the service under syatem administration > system configuration>knowledge management> content management> repository services. Attached is the error log I am getting after deployment. Could you please suggest a solution to this, if you ahve any idea. Also, it would be helpful if you could tell me what exactly is the KEY in the code above( is it the unique name we give to the property?).

Answers (1)

Answers (1)

0 Kudos

Hi,

You can use the KM Activity Reporting to track this, but it is all written to a flat file which should be then parsed to get the right results.

http://help.sap.com/saphelp_nw70/helpdata/EN/45/74eeda9ba26975e10000000a114a6b/frameset.htm

One more idea would be to write a Repository Service or Repository Filter, where you implement logic to write user access information into some DB Table. For example check already existing Access Statistics Service in KM which has similar functionality.

To add Web Trend java script to track access information will be tricky as there is no central place to add this to have the access information. One idea would be to call the web trends url from Repository Service, so that the information is passed to web trends. So here on server side a http call to web trends should happen. You can check HTTPClient API of apache to do this.

Regards,

Praveen Gudapati

Former Member
0 Kudos

Hi Praveen,

Thanks a lot for reply.

I know the part "on server side a http call to web trends should happen"

But my concern is how to get from user request

1)Which folder/document he is trying to access

2) Is he trying to download

Regards,

Ganga

0 Kudos

Hi,

When you start implementing your custom Repository Service or Repository Filter you will see that you always have reference to IResource object, which is nothing but Folder/Document.

From IResource you can get ResourceContext and ResourceContext has the Users object.

So the code should be:

IResourceContext resourceContext = IResource.getContext();
resourceContext.getUser();

When ever the user accesses the document, it should be counted as read, you need not differentiate this from download as both are same from KM perspective.

Greetings,

Praveen Gudapati

Former Member
0 Kudos

Hi Praveen,

Since the flow of request for KM resource is like "J2EE dispatcher --> Gateway Servlet --> PRT Dispatcher Servlet --> KM Component (Doc IView / Navigation IView) --> Repository Framework --> Repository Manager(RM) --> KM Resource"[as guided by you]

can we do as below:

Once Request comes to RM, we can put code snippet in it

which will

a) Identify resource requested

b) Identify user

c) send these details to WebTrends(How to do this I know...we have code for this)

As per my knowledge, I think it is fairly possible.

Please GUIDE.

Regards,

Ganga

0 Kudos

Hi,

Implementing a Repository Manager is alot more complex than Implementing a Repository Service.

You generally implement a Repository Manager, when you have a new type of repository that you want to expose in KM. For example you have Share Point Sever and you want to expose it in KM, but dont have a Repository Manager that supports it in KM.

How will you integrate this functionality into exisiting KM Repository Managers?

So from my perspective implementing a Repository Service is the best way to handle this. You can also check already existing Access Statistics Service in KM which has similar functionality. So SAP also uses Repository Service to implement such functionality.

Regards,

Praveen Gudapati

Former Member
0 Kudos

Hi Praveen,

If we have to use Repository Service(RS), how can we make sure that

RS gets invoked whenever resorce is requested to RM, so that we can send the details of request to Web Trends server.

Regards,

Ganga.

0 Kudos

Hi,

Repository service can be assigned to Repository managers and registered to resource events(ResourceEvent.CREATE_CHILD). So every time an event occurs on the resource your Repository service gets invoked. As I already mentioned, for your usecase check the codes of Access Statistics Service.

Also check this:

https://wiki.sdn.sap.com/wiki/display/KMC/KMDocumentHits-Code+Program

https://forums.sdn.sap.com/thread.jspa?threadID=119232

Regards,

Praveen Gudapati

Former Member
0 Kudos

Hi Praveen & All,

I have java script code used for sending data to Web Trend server.

I have written Repository Service(RS) with the purpose of sending info of KM document read to Web Trend server.

I am able to collect all info required in RS, but not getting how to send this data to WebTrend server since I have java script code.

In one website it says:

Place the include file that contains the JavaScript code in a location accessible to every page of your Web site.

Place an include statement on all your Web site pages. Be sure to use the correct file extensions.

Do we have java code instead of java script code for WebTrend

Please guide.

Regards,

Ganga.

0 Kudos

Hi,

As we cannot run any javascript on server side, you should check what is done in that javascript and if any submit or url calls are done in this javascript and do the same using HTTPClient api's.

You can also check with WebTrend guys, if there is API, which you can directly call from server side. I think webtrends is developed in .NET, so there should be some webservice which may be can solve your problem.

For WebTrends questions, ask questions in some WebTrends forums.

Regards,

Praveen Gudapati

Former Member
0 Kudos

Hi Ganga,

did u resolved this issue,

Please help me. I am new to KM, my requirement is

if a user views a XMl document ,the details of the time ,date and details of user needs to be captured and shown below the document.every time for a new read ,it appends the list.

Please give me any step by step example for this .

Thanks in advance .

Nitesh