cancel
Showing results for 
Search instead for 
Did you mean: 

How to get read the value from portalapp.xml of a KM service

Former Member
0 Kudos

Hi All,

I am working on KM Services. The service is for setting the VALIDUNTIL date of the documents uploaded to the KM. The VALIDUNTIL date is based one of the custom property.

If the property is A then the VALIDUNIT date is +1 year from the date of creation.. like tat for B and C.

I want to store the no of years for A,B and C in a properties file, so tat it can be changed later.

I have tried putting it into a resource bundle and accessing it but I am not able to access it.

What I am thinking is adding these value in portalapp.xml. Can any of u suggest how to get read the value from portalapp.xml of a KM service at runtime.

Regards

George

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

		<YourService> service = (<YourService>)PortalRuntime.getRuntimeResources().getService(<YourService>.KEY);
		String value = service.getContext().getServiceProfile().getProperty("key");

You can read a value from portalapp.xml using the above.

Former Member
0 Kudos

Thanks Ankur,

But I am not able to read... this is the code I have tried

RFServiceWrapper myServ = (RFServiceWrapper)PortalRuntime.getRuntimeResources().getService(RFServiceWrapper.KEY);

Please correct me if I am wrong

Regards

George

Former Member
0 Kudos

I am assuming RFServiceWrapper is your interface of the service.

When you execute this code, do you get any value for

myServ 

object. If not

what is the value of the Static variable KEY defined in the interface

RFServiceWrapper

Former Member
0 Kudos

Hi Ankur,

The interface is ....

public interface IRFServiceWrapper extends IService{

public static final String KEY = "com.sap.km.service.KMService";

}

The exception i am getting is not able to find the service..."KMService".

Regards

George

Former Member
0 Kudos

Hi George,

I have the same problem. How did you resolve it?

Best regards

Irene

Former Member
0 Kudos

Hi Iryna,

I used .properties file for storing the properties..

Cheers

George

Former Member
0 Kudos

Hi George, thank you for the quick answer. Wich properties do you mean?

Regards Iryna

Former Member
0 Kudos

Hi Iryna,

I have some proj specific properties... tats wat I have included...

Regards

George

Answers (1)

Answers (1)

former_member189326
Active Participant
0 Kudos

George - since you are developing a KM (Respository?) Service, you should store your configuration information for that service in the XML files in the src.config/* files included in the development project for that service.

You see a "meta" branch and a "data" branch. The "meta" branch is where the properties are defined, you can give them a default value there, too. The "data" branch represents an instance of your service, which you may or may not have in your project (this can be defined at runtime).

So, for instance, if you wanted to add a property "A" to your service, you could add the line

<attribute name="A" type="string" default="avalue"/>

to the *.cc.xml file in your "meta" branch of src.config. This would give the property a default value of "avalue".

Doing this will allow you to view and edit the configuration of the service using the KM Config iView in the portal, <i>at runtime</i>.

You may of course also use a property file, but this means you'll have to redeploy your project in order to make configuration changes.

Former Member
0 Kudos

Hi Boris,

thats nice, that you are written, but I have another Problem . I define the RFServiceWrapper properties in portapp.xml, but I need this properties in scheduler task. The line in schedulerTask run()

RFServiceWrapper rfs = (RFServiceWrapper)PortalRuntime.getRuntimeResources().getService(RFServiceWrapper.KEY);

returns Service not found error, the KEY is defined in IRFServiceWrapper.

This is one problem I have. Have you any Idea?

Thanks.

Iryna

Former Member
0 Kudos

Thanks for the answer Boris,

I have already solved this prob in a different way.

Regards

George

former_member189326
Active Participant
0 Kudos

Hi George - would you like to mark this thread as "answered" or something else that's suitable and also reward points for any answers that you found helpful? That way it will no longer show up as requiring an answer when people search for open threads.

former_member189326
Active Participant
0 Kudos

Hi Iryna - I think the solution to your problem is also what I have described above - you should put these properties in a place where KM can see them so that you can also manage them at runtime (in the *.cc.xml and *.co.xml files). My email is in my profile (hopefully visible to you), you may write me there if this is not clear.