Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
How to delete secondary content items attached to a WTDocument using Api?
Solved! Go to Solution.
Hi Vineeth,
Here is an example:
document = (WTDocument)ContentHelper.service.getContents(document);
String number = document.getNumber();
/* Get the list of ContentItem out of the passed ContentHolder This should be done after a call to ContentHelper.service.getContents( ContentHolder ). Note this will NOT return the primary content for a FormatContentHolder.*/
Vector contents = ContentHelper.getContentList(document);
int num_of_files = contents.size();
System.out.println("Removing " + num_of_files + " content items from " + number);
for (int i = 0; i < num_of_files; i++)
{
ContentItem ci = (ContentItem)contents.elementAt(i);
System.out.println("Removing content item: " + ci.getDescription());
ContentServerHelper.service.deleteContent(document,ci);
}
Thanks,
Jarrett
Hi Vineeth,
Here is an example:
document = (WTDocument)ContentHelper.service.getContents(document);
String number = document.getNumber();
/* Get the list of ContentItem out of the passed ContentHolder This should be done after a call to ContentHelper.service.getContents( ContentHolder ). Note this will NOT return the primary content for a FormatContentHolder.*/
Vector contents = ContentHelper.getContentList(document);
int num_of_files = contents.size();
System.out.println("Removing " + num_of_files + " content items from " + number);
for (int i = 0; i < num_of_files; i++)
{
ContentItem ci = (ContentItem)contents.elementAt(i);
System.out.println("Removing content item: " + ci.getDescription());
ContentServerHelper.service.deleteContent(document,ci);
}
Thanks,
Jarrett
Also you may have to check out the object to avoid locks.
Thanks,
Jarrett
Hi Jarrett,
I was go through your code.
its works for me for WTDocument.
i am facing a similar kind of issue while i am going to update the content of EPMDocument.
i will explain you my problem with this example.
My requirement is to create a EPMDoc and Iterate it.as like below.
EPMDocA.prt -- A.1 -- epmdcoa.prt (50kb Size file )
again itrate it to become,
EPMDocA.prt -- A.2 -- epmdcoa.prt (100kb Size file ).
now i am able to create EPMDocA.prt -- A.1 -- epmdcoa.prt (50kb Size file ) with my program. and also able to check out the EPMDocA.prt for updating its content with modified cotent file for A.2 version.
but i am facing below error,
java.lang.reflect.InvocationTargetException
at wt.method.RemoteMethodServer.invoke(RemoteMethodServer.java:800)
at wt.clients.util.RMIMultiPartPost.performOperation(RMIMultiPartPost.java:257)
at wt.clients.util.http.HTTPUploadDownload.performUploadOperation(HTTPUploadDownload.java:1357)
at wt.clients.util.http.HTTPUploadDownload.access$100(HTTPUploadDownload.java:54)
at wt.clients.util.http.HTTPUploadDownload$HTTPUploadDownloadThread.run(HTTPUploadDownload.java:2728)
Caused by: (wt.content.contentResource/66) wt.content.ContentException: Can not add more than one primary content to the object.
... 5 more
Please can you help me out in how i can upload modified content file for version A.2.
sample code or API will be grate help for me.
Regards,
Vivek