Google Groups Home
Help | Sign in
Copy a ContentComponent
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post will appear after it is approved by moderators
paperiniko  
View profile
 More options May 8, 10:54 am
From: paperiniko <nicolo.bevilac...@gmail.com>
Date: Thu, 8 May 2008 07:54:45 -0700 (PDT)
Local: Thurs, May 8 2008 10:54 am
Subject: Copy a ContentComponent
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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google