cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing Km document in webdynpro application

Former Member
0 Kudos

Hi All,

Is it possible to access the file which is uploaded in KM through webdynpro code?

Can anybody help in this?

Regards,

V Karthi

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member206159
Active Contributor
0 Kudos

As an example if you uploaded a document called 'abc' in document repository in

content Administrator->KM Content.

Navigate to documents folder then go to the context menu of your document abc.

Details->Settings->Properties

in the tabs click Access links tab and in the target url

copy from /irj

in the above example it would be,

'/irj/go/km/docs/documents/abc' . Use the url in your webdynpro code to access the document in KM folders

Note that you have proper permissions to that documents before accessing it.

Raghu

Former Member
0 Kudos

Hi Raghu and Hari,

Thank you very much .i'm able to download the file by giving the folder path like "/document/test".

Regards,

V Karthi

Former Member
0 Kudos

Yes its possible. Go through:

Navigate through Knowledge Management repositories and folders from a WebDynpro Application using KM API - https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f02b492c-7d76-2a10-86aa-e11e8388...

And article:

KM Versioning Using Web Dynpro Application - https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/3095f14c-29c5-2b10-f69e-edcb6f0f...

Former Member
0 Kudos

Thank you anagha for the link.

But i'm facing some issue with the code .i think there is a problem in typecasting the Iuser and moreover whn i try to print the sap user i'm getting the following error.

"sapUser Transient data: *************************************************************************** * com.sap.security.core.persistence.imp.PrincipalDatabag Tue Jun 23 10:13:29 GMT05:30 2009 * UniqueID: USER.R3_DATASOURCE.J2EE_GUEST * Type: USER * Home data source: R3_DATASOURCE * Private id part: J2EE_GUEST * * Existence not checked. * * "com.sap.security.core.usermanagement"|->"j_authscheme" (no time limit)="anonymous" *************************************************************************** Persistent data: *************************************************************************** * com.sap.security.core.persistence.imp.PrincipalDatabag Tue Jun 23 10:13:29 GMT05:30 2009 * UniqueID: USER.R3_DATASOURCE.J2EE_GUEST * Type: USER * Home data source: R3_DATASOURCE * Private id part: J2EE_GUEST * * Principal exists. * * Direct parents: * GRUP: GRUP.SUPER_GROUPS_DATASOURCE.EVERYONE * GRUP.R3_ROLE_DS.SAP_J2EE_GUEST * GRUP.SUPER_GROUPS_DATASOURCE.Anonymous Users * ROLE: * "com.sap.portal.dsm"|->"DebugControlFlag" (no time limit)= * "com.sap.security.core.usermanagement"|->"mobile" (no time limit)= * "com.sap.security.core.usermanagement"|->"uniquename" (no time limit)="J2EE_GUEST" * "com.sap.security.core.usermanagement"|->"title" (no time limit)= * "com.sap.security.core.usermanagement"|->"telephone" (no time limit)= * "com.sap.security.core.usermanagement"|->"salutation" (no time limit)= * "com.sap.security.core.usermanagement"|->"jobtitle" (no time limit)= * "com.sap.security.core.usermanagement"|->"fax" (no time limit)= * "com.sap.security.core.usermanagement"|->"department" (no time limit)= * "com.sap.security.core.usermanagement"|->"lastname" (no time limit)="J2EE_GUEST" * "com.sap.security.core.usermanagement"|->"locale" (no time limit)= * "com.sap.security.core.usermanagement"|->"timezone" (no time limit)= * "com.sap.security.core.usermanagement"|->"firstname" (no time limit)= * "com.sap.security.core.usermanagement"|->"email" (no time limit)= * "com.sap.security.core.usermanagement"|->"referenceuser" (no time limit)= * "$serviceUser$"|->"SERVICEUSER_ATTRIBUTE" (no time limit)= * "com.sapportals.portal.navigation"|->"uipmode" (no time limit)= *************************************************************************** ep5User WPUser default_namespace: com.sap.security.core.usermanagement com.sapportals.portal.security.usermanagement.User50_Impl@3ce0a8ef WPUser: (J2EE_GUEST)[com.sapportals.portal.security.usermanagement.User50_Impl@1021356271] UME user object Transient data: *************************************************************************** * com.sap.security.core.persistence.imp.PrincipalDatabag Tue Jun 23 10:13:29 GMT+05:30 2009 * UniqueID: USER.R3_DATASOURCE.J2EE_GUEST * Type: USER * Home data source: R3_DATASOURCE * Private id part: J2EE_GUEST * * Existence not checked. * * "com.sap.security.core.usermanagement"|->"j_authscheme" (no time limit)="anonymous" "

Can you please provide me the sample code for accessing the KM document through webdynpro?

Regards,

V Karthi

Former Member
0 Kudos

Hi Karthi,

if you want to access a file which is available in any km folder follow below steps.

1. check permissions. for testing purpose give full permissions to Everone.

2. create UI using webdynpro.

3. Place all required jar file which are required to use KM API in the build path.

4. Path always start from CM Repository directory. for instance in order to access Public documents folder. path would be: /documents/Public Documents/

3. in order to download/open existing file. below is code.

pathofkmfile=/documents/Public Documents/myfolder/myfile/

public final static InputStream getKmResource(String pathofkmfile){

try {

ResourceContext contex= new ResourceContext(WDClientUser.getCurrentUser().getSAPUser(););

IResourceFactory factory = ResourceFactory.getInstance();

RID rid =RID.getRID(pathofkmfile);

final IResource kmResource = factory.getResource(rid,contex);

if(kmResource==null){

throw new ResourceNotFoundException("KM Resource Not Found"+kmResource.getDisplayName());

}

return kmResource.getContent().getInputStream();

}

catch (Exception e) {

e.getStackTrace();

return null;

}

above method returns InputStream.

Once you get java.io.InputStream. you can manage to show or download or set this property of filedownload UI element.

Please refer this link: http://sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/00062266-3aa9-2910-d485-f1088c3a4d71

Hope this will help you.

Best Regards

Hari.