vittalmareddy
asked on
Adding a child to a virtual document and getting error
I tried to add a child XML based content to a XML based virtual content programatically and getting the following error. The child content and virtual content reside in the repository. Any idea why I am getting the following error.
thanks in advance
java.lang.ClassCastExcepti on: com.documentum.vdm.impl.Ad aptiveNode .
sample code
public boolean checkoutVDM(String docId){
try {
IDfCheckoutOperation coOp = clientx.getCheckoutOperati on();
//coOp.setDestinationDirec tory("E:// aaa/TempAr ea");
IDfDocument doc = (IDfDocument) session.getObject(new DfId(docId));
IDfCheckoutNode coNode;
if (doc.isVirtualDocument()){
IDfVirtualDocument vDoc = doc.asVirtualDocument( "CURRENT",false);
coNode = (IDfCheckoutNode)coOp.add( vDoc);
} else {
coNode = (IDfCheckoutNode)coOp.add( doc);
}
if (coOp.execute()) {
return true;
} else {
return false;
}
} catch(Exception ex){
ex.printStackTrace();
System.out.println("checko utVDM Error: " + ex.getLocalizedMessage());
}
return false;
}
public boolean checkinVDM(String docId){
try {
IDfCheckinOperation cio = clientx.getCheckinOperatio n();
cio.setCheckinVersion(IDfC heckinOper ation.NEXT _MAJOR);
cio.setVersionLabels("CURR ENT");
IDfDocument doc = (IDfDocument) session.getObject(new DfId(docId));
if (doc.isVirtualDocument()){
IDfVirtualDocument vDoc = doc.asVirtualDocument( "CURRENT",false);
IDfCheckinNode node = (IDfCheckinNode) cio.add(vDoc);
} else{
IDfCheckinNode node = (IDfCheckinNode) cio.add(doc);
}
if (!cio.execute())
{
return false;
}
} catch(Exception ex){
ex.printStackTrace();
System.out.println("checki nVDM Error: " + ex.getLocalizedMessage());
}
return true;
}
public boolean createVDMNode(String parentIdString, String childIdString, String versionLabel, String siblingIdString){
try {
boolean bCheckoutSuccess = checkoutVDM(parentIdString );
if (bCheckoutSuccess) {
IDfVirtualDocument vDoc = null;
IDfId parentIdObject = clientx.getId(parentIdStri ng);
IDfSysObject sysObj = (IDfSysObject) session.getObject(parentId Object);
if (versionLabel.equals("")) versionLabel = null;
if (sysObj != null){
vDoc = sysObj.asVirtualDocument(n ull,false) ;
IDfVirtualDocumentNode root = vDoc.getRootNode();
IDfId childId = session.getIdByQualificati on("dm_sys object where r_object_id='" + childIdString + "'");
IDfSysObject childObj = (IDfSysObject) session.getObject(childId) ;
IDfVirtualDocumentNode siblingNode = null;
if (!siblingIdString.equals(n ull) & !siblingIdString.equals("" )){
IDfId siblingId = session.getIdByQualificati on("dm_sys object where r_object_id='" + siblingIdString + "'");
IDfSysObject siblingObj = (IDfSysObject) session.getObject(siblingI d);
String siblingChronId = siblingObj.getChronicleId( ).toString ();
siblingNode = vDoc.find(root,siblingChro nId,"i_chr onicle_id" ,0);
}
IDfVirtualDocumentNode childVDNode = vDoc.addNode(root, siblingNode, childObj.getChronicleId(), null, false, false);
//vDoc.addNode(root, siblingNode, childObj.getChronicleId(), null, false, false);
boolean bCheckinSuccess = checkinVDM(parentIdString) ;
if (bCheckinSuccess) {
return true;
} else {
return false;
}
}
}
} catch(Exception ex){
ex.printStackTrace();
System.out.println("checki nVDM Error: " + ex.getLocalizedMessage());
}
return false;
}
thanks in advance
java.lang.ClassCastExcepti
sample code
public boolean checkoutVDM(String docId){
try {
IDfCheckoutOperation coOp = clientx.getCheckoutOperati
//coOp.setDestinationDirec
IDfDocument doc = (IDfDocument) session.getObject(new DfId(docId));
IDfCheckoutNode coNode;
if (doc.isVirtualDocument()){
IDfVirtualDocument vDoc = doc.asVirtualDocument( "CURRENT",false);
coNode = (IDfCheckoutNode)coOp.add(
} else {
coNode = (IDfCheckoutNode)coOp.add(
}
if (coOp.execute()) {
return true;
} else {
return false;
}
} catch(Exception ex){
ex.printStackTrace();
System.out.println("checko
}
return false;
}
public boolean checkinVDM(String docId){
try {
IDfCheckinOperation cio = clientx.getCheckinOperatio
cio.setCheckinVersion(IDfC
cio.setVersionLabels("CURR
IDfDocument doc = (IDfDocument) session.getObject(new DfId(docId));
if (doc.isVirtualDocument()){
IDfVirtualDocument vDoc = doc.asVirtualDocument( "CURRENT",false);
IDfCheckinNode node = (IDfCheckinNode) cio.add(vDoc);
} else{
IDfCheckinNode node = (IDfCheckinNode) cio.add(doc);
}
if (!cio.execute())
{
return false;
}
} catch(Exception ex){
ex.printStackTrace();
System.out.println("checki
}
return true;
}
public boolean createVDMNode(String parentIdString, String childIdString, String versionLabel, String siblingIdString){
try {
boolean bCheckoutSuccess = checkoutVDM(parentIdString
if (bCheckoutSuccess) {
IDfVirtualDocument vDoc = null;
IDfId parentIdObject = clientx.getId(parentIdStri
IDfSysObject sysObj = (IDfSysObject) session.getObject(parentId
if (versionLabel.equals("")) versionLabel = null;
if (sysObj != null){
vDoc = sysObj.asVirtualDocument(n
IDfVirtualDocumentNode root = vDoc.getRootNode();
IDfId childId = session.getIdByQualificati
IDfSysObject childObj = (IDfSysObject) session.getObject(childId)
IDfVirtualDocumentNode siblingNode = null;
if (!siblingIdString.equals(n
IDfId siblingId = session.getIdByQualificati
IDfSysObject siblingObj = (IDfSysObject) session.getObject(siblingI
String siblingChronId = siblingObj.getChronicleId(
siblingNode = vDoc.find(root,siblingChro
}
IDfVirtualDocumentNode childVDNode = vDoc.addNode(root, siblingNode, childObj.getChronicleId(),
//vDoc.addNode(root, siblingNode, childObj.getChronicleId(),
boolean bCheckinSuccess = checkinVDM(parentIdString)
if (bCheckinSuccess) {
return true;
} else {
return false;
}
}
}
} catch(Exception ex){
ex.printStackTrace();
System.out.println("checki
}
return false;
}
Please post the full stack trace of the error. What line is causing the ClassCastException?
The reason is simply a Casting issue, but let's find out why it's occurring.
The reason is simply a Casting issue, but let's find out why it's occurring.
Also, what version of Documentum are you using?
ASKER
com.documentum.vdm.impl.Ad aptiveNode
at com.documentum.vdm.impl.Vi rtualDocum ent.addNod e(VirtualD ocument.ja va:122)
at com.deloitte.da.cms.ems.ut ils.AmitTe stCls.crea teVDMNode( AmitTestCl s.java:323 )
at com.deloitte.da.cms.ems.ut ilss.TesTA mitPrj.tes tAbcd(TesT AmitPrj.ja va:18)
at sun.reflect.NativeMethodAc cessorImpl .invoke0(N ative Method)
at sun.reflect.NativeMethodAc cessorImpl .invoke(Un known Source)
at sun.reflect.DelegatingMeth odAccessor Impl.invok e(Unknown Source)
at java.lang.reflect.Method.i nvoke(Unkn own Source)
at org.junit.internal.runners .TestMetho dRunner.ex ecuteMetho dBody(Test MethodRunn er.java:99 )
at org.junit.internal.runners .TestMetho dRunner.ru nUnprotect ed(TestMet hodRunner. java:81)
at org.junit.internal.runners .BeforeAnd AfterRunne r.runProte cted(Befor eAndAfterR unner.java :34)
at org.junit.internal.runners .TestMetho dRunner.ru nMethod(Te stMethodRu nner.java: 75)
at org.junit.internal.runners .TestMetho dRunner.ru n(TestMeth odRunner.j ava:45)
at org.junit.internal.runners .TestClass MethodsRun ner.invoke TestMethod (TestClass MethodsRun ner.java:6 6)
at org.junit.internal.runners .TestClass MethodsRun ner.run(Te stClassMet hodsRunner .java:35)
at org.junit.internal.runners .TestClass Runner$1.r unUnprotec ted(TestCl assRunner. java:42)
at org.junit.internal.runners .BeforeAnd AfterRunne r.runProte cted(Befor eAndAfterR unner.java :34)
at org.junit.internal.runners .TestClass Runner.run (TestClass Runner.jav a:52)
at org.eclipse.jdt.internal.j unit4.runn er.JUnit4T estReferen ce.run(JUn it4TestRef erence.jav a:45)
at org.eclipse.jdt.internal.j unit.runne r.TestExec ution.run( TestExecut ion.java:3 8)
at org.eclipse.jdt.internal.j unit.runne r.RemoteTe stRunner.r unTests(Re moteTestRu nner.java: 460)
at org.eclipse.jdt.internal.j unit.runne r.RemoteTe stRunner.r unTests(Re moteTestRu nner.java: 673)
at org.eclipse.jdt.internal.j unit.runne r.RemoteTe stRunner.r un(RemoteT estRunner. java:386)
at org.eclipse.jdt.internal.j unit.runne r.RemoteTe stRunner.m ain(Remote TestRunner .java:196)
at com.documentum.vdm.impl.Vi
at com.deloitte.da.cms.ems.ut
at com.deloitte.da.cms.ems.ut
at sun.reflect.NativeMethodAc
at sun.reflect.NativeMethodAc
at sun.reflect.DelegatingMeth
at java.lang.reflect.Method.i
at org.junit.internal.runners
at org.junit.internal.runners
at org.junit.internal.runners
at org.junit.internal.runners
at org.junit.internal.runners
at org.junit.internal.runners
at org.junit.internal.runners
at org.junit.internal.runners
at org.junit.internal.runners
at org.junit.internal.runners
at org.eclipse.jdt.internal.j
at org.eclipse.jdt.internal.j
at org.eclipse.jdt.internal.j
at org.eclipse.jdt.internal.j
at org.eclipse.jdt.internal.j
at org.eclipse.jdt.internal.j
Are you passing an uninstantiated object into the insertAfterNode (i.e., siblingNode) parameter?
If you change this line:
IDfVirtualDocumentNode childVDNode = vDoc.addNode(root, siblingNode, childObj.getChronicleId(), null, false, false);
to:
IDfVirtualDocumentNode childVDNode = vDoc.addNode(root, null, childObj.getChronicleId(), null, false, false);
does that work?
Secondly, are you sure that the childObj is populated correctly?
If you change this line:
IDfVirtualDocumentNode childVDNode = vDoc.addNode(root, siblingNode, childObj.getChronicleId(),
to:
IDfVirtualDocumentNode childVDNode = vDoc.addNode(root, null, childObj.getChronicleId(),
does that work?
Secondly, are you sure that the childObj is populated correctly?
ASKER
Thanks for info, I already verified by pass valide sibilingNode and also null, both cases issue is same.
I also verified with pdf as virtual document and childs components are also pdf with same code it works fine.
my actual requirement is virtual document is xml and child component also xml, this case it is throwing exception as specified.
I also verified with pdf as virtual document and childs components are also pdf with same code it works fine.
my actual requirement is virtual document is xml and child component also xml, this case it is throwing exception as specified.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
we are using xml applicaiton, but now i don't have enviroment to verify XML Application on disabling anverify.
ASKER