Skip to Content
0
Former Member
Oct 27, 2009 at 06:14 AM

Nullpoint Exception while Uploading a File

26 Views

Hi plz some one help am getting Nullpoint Exception when i run with this code

And am getting at IWDModifiableBinaryType is deprecat Warning hope some one do help ASAP

ThanQ in Advance.

try

{

IWDAttributeInfo attributeInfo = wdContext.nodeFile().getNodeInfo().getAttribute("fileData");

IWDModifiableBinaryType binaryType = (IWDModifiableBinaryType) attributeInfo.getModifiableSimpleType();

byte[] fileByteArray = wdContext.currentFileElement().getFileData();

IWDClientUser wdClientUser = WDClientUser.getCurrentUser();

com.sap.security.api.IUser sapUser = wdClientUser.getSAPUser();

IUser ep5User =WPUMFactory.getUserFactory().getEP5User(sapUser);

ResourceContext rcontext = new ResourceContext(ep5User);

RID rid = RID.getRID("/documents/MCGM Department/City Eng/");

IResourceFactory factory = ResourceFactory.getInstance();

ICollection collection = (ICollection) factory.getResource(rid,rcontext);

ByteArrayInputStream byetArrStream = new ByteArrayInputStream(fileByteArray);

Content con = new Content( byetArrStream , "application/octet-stream", -1L,"UTF-16");

IResource newResource = collection.createResource(binaryType.getFileName(), null, con);

long contentLen = newResource.getContent().getContentLength();

if (contentLen < 0)

{

}//if

else

{

wdComponentAPI.getMessageManager().reportSuccess("File uploaded is "+ binaryType.getFileName());

}//else

}//try

catch (Exception e)

{

wdComponentAPI.getMessageManager().reportSuccess ("error" + e.toString());

}

//@@end

}

Vita