on 02-10-2009 10:06 AM
Hi,
I would like to test if a km file exists but cannot make it work. I have the following code:
String numLiv = "http://<server>:<port>/irj/go/km/docs/MyRepository/myFile.pdf";
java.io.File myFile = new File(numLiv);
if (myFile.isFile()) {
wdContext.currentContextElement().setPath(numLiv);
messageMgr.reportSuccess("Mon fichier existe !!");
}
I have no idea what is wrong, I also tried with myFile.exists() but every time it returns false. Th efile do exist in my KM.
Thank you for your help.
Thibault Schalck
Hi,
Did You try this code:
URL url = new URL( "http://<server>:<port>/irj/go/km/docs/MyRepository/myFile.pdf" );
URLConnection urlConn = url.openConnection();
urlConn.setDoInput( true );
InputStream stream = urlConn.getInputStream();
//stream.available(); do sth with stream, eg. write to local file,
stream.close();
Or, the better way, you should use Repostiory Framework API :
com.sapportals.portal.security.usermanagement.IUser user=
WPUMFactory.getUserFactory().getEP5User( WDClientUser.getCurrentUser().getSAPUser() );
RID rid = RID.getRID( "/MyRepository/myFile.pdf" );
ResourceContext resourceContext = new ResourceContext( user );
if ( ResourceFactory.getInstance().checkExistence( rid, resourceContext ) == true ) {
//document exists!.
}
Hope it helps
Jakub Krecicki
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi
check this
/people/community.user/blog/2008/09/03/how-to-download-km-documents-using-web-dynpro-java
let me know am i reached u r problem
bvr
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.