on 12-03-2009 5:08 AM
Hi Frnds,
Am working with Webdynpro Java I need small help plz.
File Upload in KM with tutorials and export Post in SDN I done File Upload but the thing is my requirement is not only file store in KM I have few more input fields with file Upload(like date File ID Extrau2026 min 5 of them).
So when I upload file along with that file name I want upload this information also as text in KM.
@ km
Folder layout set Iu2019v already done need full things like I created properties and add to folder layout set, but when I upload file through WDJ file is uploading successfully but not along with other input fields.
So wht I have do for that I hope I am very clear with my problem plz if u know any thing about this do help me ASAP
ThanQ n Regards,
vita
Hi,
IPropertyName custProperty =
new PropertyName( "tp://"ur namespace".com/xmlns/cm",""prop_id"");
//assigning the value to the property
IProperty property = new Property("Prop_id",""ur values"");
//setting the property to the resource
resource.setProperty(prop1);
Regards,
Naga
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
after you created a file in KM via KM API, will return you the created file as a resource
for eg:
IResource newResource = folder.createResource(fileName,null, fileContent);
now the below code will add the custom properties defined in the Km
IPropertyName userID_Property =
new PropertyName( "http://some.com/xmlns/cm","Property_ID");// here the property id and name space are which you have created in KM
// assigning the value to the property
IProperty prop1 = new Property("Property_ID","ur value");// the same property id from the above statement
// setting the property to the resource
newResource.setProperty(prop1);
Regards,
Naga
Hi Naga Rau,
Am getting File Not Found Exception While Uploading File Can u chk This code plz it very kind if u do this for me plz and replay me Asap thanQ
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/Department");
IResourceFactory factory = ResourceFactory.getInstance();
ICollection collection = (ICollection) factory.getResource(rid,rcontext);
String fileName = wdContext.currentFileElement().getTRescource().getResourceName();
InputStream inputStream = wdContext.currentFileElement().getTRescource().read(false);
File destfile = new File(fileName);
FileInputStream fin = new FileInputStream(destfile);
fin.read();
Content content = new Content(inputStream,"application/octet-stream",-1L,"UTF-16");
IResource newResource = collection.createResource(fileName, null, content);
long contentLen = newResource.getContent().getContentLength();
if(contentLen < 0)
{
}//if
else
{
//wdComponentAPI.getMessageManager().reportSuccess("File uploaded"+ binaryType.getFileName());
IWDControllerInfo controllerInfo = wdControllerAPI.getViewInfo().getViewController();
String first1 = "File uploaded Successfully!!!!!!";
IWDConfirmationDialog dialog = wdComponentAPI.getWindowManager().createConfirmationWindow(first1, controllerInfo.findInEventHandlers("Ok"),"Ok");
dialog.open();
}
Hi,
The Exception is coming for this code block of your code:
File destfile = new File(fileName);
FileInputStream fin = new FileInputStream(destfile);
fin.read();
To upload a file,
create a context attribute of type com.sap.ide.webdynpro.uielementdefinitions.Resource, and bind this attribute to Resource property of fileupload UI Element, i think you did it.
To place file into KM.
//to get ep5 user
IWDClientUser wdClientUser =WDClientUser.getCurrentUser();
com.sap.security.api.IUser sapUser = wdClientUser.getSAPUser();
com.sapportals.portal.security.usermanagement.IUser ep5User= WPUMFactory.getUserFactory().getEP5User(sapUser);
// place file into km
IResourceFactory factory = com.sapportals.wcm.repository.ResourceFactory.getInstance();
ResourceContext context =new ResourceContext(ep5User());
ICollection folder = (ICollection) factory.getResource(RID.getRID("/documents/Department"),context);
Content attachedContent=new Content(wdContext.currentFileElement().getTRescource().read(false)
,wdContext.currentFileElement().getTRescource().getResourceType().getHtmlMime(),-1);
IResource newResource = folder.createResource(wdContext.currentFileElement().getTRescource().getResourceName(),null, attachedContent);
Regards,
Naga
Edited by: Naga Raju Meesala on Dec 3, 2009 5:10 PM
Hi Naga Ragu,
Thank u for ur Time For me ,
am getting this erro after adding above code
The initial exception that caused the request to fail, was:
java.lang.NullPointerException
at at com.sap.tc.webdynpro.clientserver.window.ConfirmationDialogDelegate.<init>(ConfirmationDialogDelegate.java:79)
at at com.sap.tc.webdynpro.clientserver.cal.ClientComponent.createConfirmationWindow(ClientComponent.java:987)
at at com.mcgm.UploadTendersView.onActionSubmit(UploadTendersView.java:232)
at at com.mcgm.wdp.InternalUploadTendersView.wdInvokeEventHandler(InternalUploadTendersView.java:152)
at at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)
... 28 more
plz give some inputs ASAP
ThanQ Dear,
vita
Hi Naga Ragu,
ThanQ for ur Help can u do bit more plz,
Am trying to add customised Properties in my WDJ program but am getting error
As u said i added Like this
IPropertyName userID_Property = new PropertyName("http://default.com/xmlns/cm","tDescription");
**IProperty prop1 = new Property("PropertyID","test");// Getting Error Over this line **
resource.setProperty(prop1);
the above code added affter
Content attachedContent=new Content(wdContext.currentFileElement().getFileResource().read(false)
,wdContext.currentFileElement().getFileResource().getResourceType().getHtmlMime(),-1);
IResource resource = folder.createResource(wdContext.currentFileElement().getFileResource().getResourceName(),null, attachedContent);
Plz give me some input am waiting ur replay,
ThanQ n Regards,
Vita
Need help
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Saleem ,
ThanQ for Ur Link but then one am trying with my code its nothing displaying @ Description
my Code is :
IPropertyName propertyName = new PropertyName("http://sapportals.com/xmlns/cm","TDescription");
IProperty property = new Property(propertyName, "testingDescription");
resource.setProperty(property);
Hear TDescription is i've created Property @ Property metadata and added to System Group and that Property i've add to km Folder layout and @Km foder i can able to see TDescription along with NAME, Size, LOCK,Modified, Modified By.
when i upload file, the File is uploading Susccess fully but not the description which am entering along with file selection .
plz Help me ASAP.
ThanQ n Regards,
vita.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
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.