on 2008 Nov 20 7:09 AM
Hi,
we have an XML string which we need to write into an XML file in KM.
could someone please suggets code to do this.
Thanks,
Rocky
Hi
Please find the code
IWDClientUser wdClientUser = WDClientUser.getCurrentUser();
com.sap.security.api.IUser sapUser = wdClientUser.getSAPUser();
//create an ep5 user from the retrieved user
IUser ep5User = WPUMFactory.getUserFactory().getEP5User(sapUser);
IResourceContext resourseContext = new ResourceContext(ep5User);
RID pathRID =
RID.getRID(
"/documents/"
+ "/News");
IResourceFactory resourseFactory = ResourceFactory.getInstance();
//get an instance of the current folder under which we have to create subfolders
ICollection collection =
(ICollection) resourseFactory.getResource(
pathRID,
resourseContext);
File tempFile = new File("temp.xml");
tempFile.createNewFile();
FileWriter writer = new FileWriter(tempFile);
writer.write(str);
writer.close();
BufferedInputStream bufInStream =
new BufferedInputStream(new FileInputStream(tempFile));
Content con = new Content(bufInStream, "byte", -1);
com.sapportals.wcm.repository.IResource resource = null;
// Creating XML File
resource =
collection.createResource(ParentTitle + ".xml", null, con);
} catch (NotSupportedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (AccessDeniedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SetPropertiesException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (WDUMException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ResourceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UserManagementException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
65 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.