cancel
Showing results for 
Search instead for 
Did you mean: 

Read a file inside our par file

Former Member
0 Kudos
167

Hello everyone,

we have created a PAR file and deployed it to the portal successfully. Inside the service we are reading a file named keywords.properties which is accessed via an absolute path on the file system.

We have now placed the keywords.properties inside the PAR file but are not quite sure how to access it.

Question:

We use a simple File class to access the file. Since we do not have a ServletContext or anything similar how do we read this file inside the PAR or how do we get a path where the file resides?

Points WILL be rewarded. Thank a lot in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Thank you Detlev.

Our service implements the com.sapportals.wcm.service.IService interface, not com.sapportals.portal.prt.service.IService

How to I get an IServiceContext?

or

Should we use com.sapportals.portal.prt.service.IService interface?

Former Member
0 Kudos

It is a IService, then your object should implement the following method which should give you acess to IServiceContext. If it is not there then put the following method in your code which comes from IService.

public void init(IServiceContext serviceContext){
		
}

detlev_beutner
Active Contributor
0 Kudos

Hi Prakash, hi Sebastian,

so, what you are developing is a "Global KM service", not a portal service. Prakash: Just putting an <i>init</i> method into it won't do it, for it wouldn't be called by the framework...

Anyhow, you will have a WrapperService within your project (implementing a portal service), at least for the need to register the application classloader, won't you?!

In this case, it might make sense to implement both interfaces together, or, if you still want to seperate them, implement a (portal)service method getPrivateResourcePath which just passes this call to the serviceContext (and returns the return value). This one you could call from the KM global service.

Hope it helps

Detlev

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

Can somebody tell me that from where can I can I get the jar file for <b>com.sapportals.wcm.service.IService</b>

Regards,

Manish

Former Member
0 Kudos

My appologies. I am writing a "Global KM Service" and Detletv'slast post actually gave me the correct path. I will now try to read the file from this location. Thank you all for your help. Point rewards will follow shortly.

Former Member
0 Kudos

Hi Sebastian,

Are you writing a portal service or a KM Service?

Prakash

detlev_beutner
Active Contributor
0 Kudos

Hi Sebastian,

> Inside the service we are reading a file

If you have the need to access the file from within a service, use <i>getPrivateServicePath</i> on the <i>IServiceContext</i> object; see https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/javadocs/nw04/sp12... runtime/com/sapportals/portal/prt/service/iservicecontext.html#getprivateservicepath() for details.

Hope it helps

Detlev