cancel
Showing results for 
Search instead for 
Did you mean: 

Web Dynpro application accesing EP content file?

Former Member
0 Kudos

Hi

I am creating aapplication in Web Dynpro (Java). It will be a simple file editor.

I don't know how I can get access to files on EP. I have to get a file from the EP content (for example Documents/test.txt), edit it and send the edited file to the EP content. How can I do it?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

If you place the file inside

<Drive Name>:\usr\sap\<server name>\<instance like JC00..>\j2ee\cluster\server0\

You can use the Obsolute path..

You can use code some thing like the following to get the file and you can sent.

File f = new File(".//version.txt");

wdComponentAPI.getMessageManager().reportWarning(" file path : "+f.toString());

version.txt if the file name present in server folder.

You can use FilInputStream or File Reader to read it.

You can send this file instance. Try this out. It must work.

Hope it helps.

Former Member
0 Kudos

It doesn't work 😕

I can see this file here - https://HOSTNAME:PORT/irj/go/km/docs/documents/test.txt

How can I get to it (read, change and replace)?

Edited by: Marcin Rozanski on Jul 3, 2008 6:51 PM

PradeepBondla
Active Contributor
0 Kudos

Hi,

Here are the links which will help you in reading text file from KM

/thread/90181 [original link is broken]

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/05c7e2ae-0a01-0010-ca98-fe42dbe0...

regards,

Pradeep

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

i have same scenario for the XML file. you have to read the file from the KM (the location where u have stored) as a resource.

after reading the file i have created input fields to get the values from the file and later edition by user,from KM deleted the existing file and replaced the old one with the new one.

Here i am giving the code example:-

ArrayList arryList = new ArrayList();

arryList = kmevents.getAllEvents(Entity, msgMngr, userInfo);

public ArrayList getAllEvents(

String Entity,

IWDMessageManager mgr,

UserInfo info) {

//creates an instance of Userinfo

ArrayList arrayList = new ArrayList();

kmPath = FILE PATH

pathRID = RID.getRID(kmPath);

try {

collection =

(ICollection) resourseFactory.getResource(

pathRID,

resourseContext);

resourceList = collection.getChildren();

resourceListIterator = resourceList.listIterator();

int count = 0;

while (resourceListIterator.hasNext()) {

resource = resourceListIterator.next();

if (resource.isCollection()) {

ArrayList list = new ArrayList();

list = getAllEventsFromFolder(file Path + resource.getName());

int i = count;

for (int j = 0; i < (count + list.size()); i+, j+) {

arrayList.add(i, (IResource) list.get(j));

}

count = i;

}

}

} catch (Exception e) {

e.printStackTrace();

}

return arrayList;

}

public ArrayList getAllEventsFromFolder(String folderName) {

//creates an instance of Userinfo

ArrayList arrayList = new ArrayList();

RID pathRID = RID.getRID(folderName);

try {

ICollection collection =

(ICollection) resourseFactory.getResource(

pathRID,

resourseContext);

IResourceList resourceList = collection.getChildren();

IResourceListIterator resourceListIterator =

resourceList.listIterator();

while (resourceListIterator.hasNext()) {

resource = resourceListIterator.next();

if (resource.isCollection()) {

continue;

} else

arrayList.add(resource);

}

} catch (Exception e) {

e.printStackTrace();

}

return arrayList;

}

Hope that may help you.....

Regards,

Deepak