on 01-18-2006 10:27 AM
Hi,
I am facing problem in copying .xml extension files from one folder to other.. But the same code works for .properties extensions..
This is my code and this is the error code
thanks
RID rid = null ;
try
{
IUser user = WPUMFactory.getServiceUserFactory().getServiceUser("cmadmin_service");
ResourceContext context = new ResourceContext(user);
// rid = RID.getRID("/documents/ContentPath.properties");
rid = RID.getRID("/documents/a.xml");
System.err.println(" ---------- strDestCollectionPath Original File RId --" + rid.toString() );
IResourceFactory resourceFactory = ResourceFactory.getInstance();
System.err.println(" ------- -2 -------3");
IResource origResource = resourceFactory.getResource(rid, context);
System.err.println(" ------- -1 ----3-strDestCollectionPath --" );
rid = null;
rid = RID.getRID("/documents/cvs/cvsFn/Adm/tm");
System.err.println(" ------- 0 --3-----");
ICollection tempcol = (ICollection) resourceFactory.getResource( rid, context );
if( tempcol != null )
{
// tempcol.createResource( "ContentPath.properties" , null , null);
tempcol.createResource( "a.xml" , null , null);
String strDestCollectionPath = tempcol.getRID().toString();
// rid = RID.getRID( strDestCollectionPath + "/" + "ContentPath.properties");
rid = RID.getRID( strDestCollectionPath + "/" + "a.xml");
IResource destResource = resourceFactory.getResource(rid, context);
com.sapportals.wcm.repository.ICopyParameter icpParam = new CopyParameter(true, true, true, true);
System.err.println(" ---------- strDestCollectionPath dest RId --" + rid.toString() );
System.err.println(" destResource.getRID() -- " + destResource.getRID().toString() ) ;
IResource copied = origResource.copy( destResource.getRID(), icpParam);
System.err.println(" ------- 8 -------");
}
else
{
System.err.println(" ------- 11 --tempcol is NULL----");
}
}
catch(ResourceException ex)
{
ex.printStackTrace();
}
catch( UserManagementException ex )
{
ex.printStackTrace();
}
// Error Stack
#1.5#000D601747FC00520000001E00001A0400040A9F45456E77#1137579085064#com.sap.portal.ivs.semantic.iViewService#sap.com/irj#com.sap.portal.ivs.semantic.iViewService#pkiran#1031####c8324880880a11dabb92000d601747fc#SAPEngine_Application_Thread[impl:3]_32##0#0#Error#1#/System/Server#Java###Failed to get application IPropertyContentProvider: #1#pcd:com.sap.portal.system/applications/Layouts/components/R1Col1R2Col4# #1.5#000D601747FC00570000004600001A0400040A9F4699C40B#1137579107377#System.err#sap.com/irj#System.err#pkiran#1031####d42c6260880a11daa17e000d601747fc#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain### -
Component : pcd:portal_content/PKWF/pkIviewFolder/ivcrProspct
Component class : com.cvs.dynCrProspects
User : pkiran
at com.sapportals.portal.prt.core.PortalRequestManager.handlePortalComponentException(PortalRequestManager.java:969)
at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:343)
at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:215)
at com.sapportals.portal.prt.pom.PortalNode.service(PortalNode.java:646)
at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
at com.sapportals.portal.prt.core.PortalRequestManager.runRequestCycle(PortalRequestManager.java:753)
at com.sapportals.portal.prt.connection.ServletConnection.handleRequest(ServletConnection.java:232)
at com.sapportals.portal.prt.dispatcher.Dispatcher$doService.run(Dispatcher.java:522)
at java.security.AccessController.doPrivileged(Native Method)
at com.sapportals.portal.prt.dispatcher.Dispatcher.service(Dispatcher.java:405)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.servlet.InvokerServlet.service(InvokerServlet.java:153)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:385)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:263)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:340)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:318)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:821)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:239)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:147)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)
at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:162)
Caused by: com.sapportals.portal.prt.component.PortalComponentException: Exception during PageProcessorComponent.doContent()
at com.sapportals.portal.htmlb.page.PageProcessorComponent.doContent(PageProcessorComponent.java:139)
at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:209)
at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114)
at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
... 29 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.sapportals.htmlb.page.DynPage.doProcessCurrentEvent(DynPage.java:172)
at com.sapportals.htmlb.page.PageProcessor.handleRequest(PageProcessor.java:115)
at com.sapportals.portal.htmlb.page.PageProcessorComponent.doContent(PageProcessorComponent.java:134)
... 32 more
Caused by: java.lang.NullPointerException
at com.cvs.dynCrProspects$dynCrProspectsDynPage.CreatePrspctPublicFolder(dynCrProspects.java:236)
at com.cvs.dynCrProspects$dynCrProspectsDynPage.onCreateKMPrspct(dynCrProspects.java:117)
... 39 more
#
Is there anything I am missing
Please help me out
thanks
pk
Hi,
I cannot say what should be the problem, seems you are getting origResource=null when getting the a.xml, but this is only a guess.
Maybe a part of my EventHadlerService code will help:
...
// destination collection RID
destRid = destCollection.getRID();
// resource to copy - RID
resRid = resource.getRID();
// target RID for copied resource
// you can use something better like RID.append(RID)...
RID target = RID.getRID(destRid.toString()+ RID.PATH_SEPARATOR+resource.getName());
// properties
IPropertyMap prop_map = resource.getProperties();
// create a copy...
IResource copy = resource.copy(target, new CopyParameter(true, true));
// if not OK
if (copy == null) {
... Error...
}
...
This works for me. Should work for you too
Let me know.
Romano
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Romono and Dirk,
I am still getting the same error..
Dirk,
I am not getting you...
If you go thru the code , actually I am copying from one folder to other..
Before creating a empty file in the destination folder, if I try to copy the file to the destination file .. it throws error... hence I created an empty file and overwriting( Not requirement ) the file...
however this code works for .doc .properties files but it complains on xml files
what could be the reason .. can you please explain
thanks
pk
Dirk,
that interest me - so the code is not OK?
What is the problem with
resource.copy(destRID, copyParameters)
?
That means I have to create an empty resource
newResource = destCollection.createResource(name, lockProperties)
in the dest collection and then copy it
copyResource = newResource.copy(RID, copyParameters)
or copy it by creating a new one with the same content and properties
destCollection.createResource(name, propMap, content)
If you think you know what is bad, give an example what is right please.
Romano
Hi!
>that interest me - so the code is not OK?
No, I think the code is ok. Since you reused 'rid' for
the destination collection I was a bit confused.
You copy /documents/a.xml to /documents/cvs/cvsFn/Adm/tm/a.xml
Before that you create the destination resource as an empty file. But you choose to overwrite it in your CopyParameters, so it should be ok.
The stack trace you posted contains a NullPointerException:
Caused by: java.lang.NullPointerException
at com.cvs.dynCrProspects$dynCrProspectsDynPage.CreatePrspctPublicFolder(dynCrProspects.java:236)
at com.cvs.dynCrProspects$dynCrProspectsDynPage.onCreateKMPrspct(dynCrProspects.java:117)
This exception does not appear in a component which is usually taking part in copying a resource from /documents to /documents.
Therefore I asked you to post the stack trace which is printed as a direct result of the failed copy.
bye, Dirk
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
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.