cancel
Showing results for 
Search instead for 
Did you mean: 

Need urgent help!!!!

Former Member
0 Kudos

I have a local web dynpro project that I created and I am trying to create a KM folder. Everything goes fine with it until I add the following line of code:

IResourceFactory factory = ResourceFactory.getInstance();

ICollection folder = (ICollection) factory.getResource(aRid,resourceContext);

There are no compilation errors or build errors and it says it deploys fine. However, with in Design Time of guided procedures, I go to create a callable object of type Web Dynpro Component (GP Interface) and when I highlight it, it has nothing for the code or description and acts like the description was never created for it. I removed the code above and everything below and tried to deploy and it works fine. I was just wondering what would be causing this and what the solution is. I am at a total loss.

Thanks in advance.

Accepted Solutions (0)

Answers (1)

Answers (1)

yogesh_galphade
Contributor
0 Kudos

Create a file node containing 2 attributes filename and filedata.This filename can be used to access the name of the file.The data stored in the file is being passed as a binary stream.

Therefore the filedata should be of binary type.

fileelement = wdContext.createFilenodeElement();

wdContext.nodeFilenode().bind(fileelement);

/Make a simple type of that type/

IWDAttributeInfo attInfo = wdContext.nodeFilenode().getNodeInfo().getAttribute("filedata");

ISimpleTypeModifiable type = attInfo.getModifiableSimpleType();

Following is the code for uploading files

/*Get an object of current Portal user */ 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);

ResourceContext context = new ResourceContext(ep5User);

/*Give the path to KM in the variable path */

RID rid = RID.getRID(path);

IResourceFactory factory =

ResourceFactory.getInstance();

ICollection folder = (ICollection) factory.getResource(rid,context);

Using the upload element we can upload the files to a location in the server drive

/*temperory location for writing */

String location = u201Cgive the location hereu201D;

String fileName = location+fileelement.getFilename();

file = new File(fileName);

/Create an output stream for writing to the temperory location/

FileOutputStream out = new FileOutputStream(file);

out.write(fileelement.getFiledata());

out.close();

/From the temporary location read the file using an input stream/

FileInputStream fin = new FileInputStream(fileName);

fin.read();

/*Using this input stream we can write to the repository

Content content = new Content(fileelement.getFiledata(),fileelement.get) */

Content content = new Content(fin,"byte", -1);

IResource newResource = folder.createResource(fileelement.getFilename(),null, content);

After uploading files to KM repository delete the file from its temporary location .Close the input stream when you have uploaded

fin.close();

file.delete();

write the above code within a try-catch block. After writing the code organize imports .

These are the imports to be organised

import com.sapportals.portal.security.usermanagement.IUser;

import com.sapportals.wcm.repository.Content;

import com.sapportals.wcm.repository.ICollection;

import com.sapportals.wcm.repository.IResource;

import com.sapportals.wcm.repository.IResourceContext;

import com.sapportals.wcm.repository.IResourceFactory;

import com.sapportals.wcm.repository.IResourceList;

import com.sapportals.wcm.repository.IResourceListIterator;

import com.sapportals.wcm.repository.ResourceContext;

import com.sapportals.wcm.repository.ResourceFactory;

import com.sapportals.wcm.util.uri.RID;

import com.sapportals.wcm.util.usermanagement.WPUMFactory