Hi list,
I try to copy a Instance of a ContentComponent (as ImageComponent,
QueryComponent etc.) with VCM/DP api.
This is my code (temp is an istance of QueryComponent):
-----------------------------------------------------------------
//Retrieve ContentType of temp
ContentType ct = (ContentType) temp.getObjectType();
//Save a XML of Component temp
String newXml = temp.toXML();
//Generate new GUID
String guid = GUID.generateString();
//Make new XML
//Moify XML
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(new InputSource(new
StringReader(newXml)));
NodeList nl = document.getElementsByTagName("VignVCMId");
nl.item(0).removeChild(nl.item(0).getChildNodes().item(0));
nl = document.getElementsByTagName("id");
nl.item(0).removeChild(nl.item(0).getChildNodes().item(0));
nl.item(0).appendChild(document.createTextNode(guid));
//Preparing output
StringWriter salida = new StringWriter();
TransformerFactory.newInstance().newTransformer().transform(new
DOMSource(document), new StreamResult(salida));
out.println("<textarea cols='50' rows='20'>");
out.println("New XML: "+ salida);
//copia is a name of new ContentComponent
ContentComponent copia = null;
ObjectType ot = temp.getObjectType();
//Retrieve copia from a newXML
copia = (ContentComponent)ManagedObject.importXML(new
ObjectTypeRef(temp.getObjectType()), salida.toString(), false);
--------------------------------------------------------------------------- -------
When I try to print a value of copia.toXML() the value of VignVCMId is
empty.
If I try to commit the object copia (copia.commit()), I encountred an
error;
javax.ejb.RemoveException.
We have any idea?
Thanks in advance
Nico