Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
Using utility I am deleting primary content of WTDocument. It is deleting the primary content but in the version history of the WTDocument, column "Open Associated Content" is still having primary content icon. How to delete this or set it blank?
Code I am trying is -
First Code -
WTDocument latest = (WTDocument)wt.vc.VersionControlHelper.service.allVersionsOf(tempDoc).nextElement();
boolean enforce = wt.session.SessionServerHelper.manager.setAccessEnforced(false);
FormatContentHolder holder = null;
try {
if(latest != null){
holder = (FormatContentHolder) ContentHelper.service.getContents(latest);
List<?> items = ContentHelper.getContentListAll(holder);
for (int i = 0; i < items.size(); i++) {
ContentItem item = (ContentItem) items.get(i);
ContentServerHelper.service.deleteContent(holder, item);
}
holder = (FormatContentHolder) PersistenceHelper.manager.refresh(holder);
}
} catch (WTException e) {
System.out.println(".deleteContents:"+e);
} finally {
SessionServerHelper.manager.setAccessEnforced(enforce);
}
Second Code -
WTDocument latest = (WTDocument)wt.vc.VersionControlHelper.service.allVersionsOf(tempDoc).nextElement();
CheckoutLink link = wt.vc.wip.WorkInProgressHelper.service.checkout(latest, wt.vc.wip.WorkInProgressHelper.service.getCheckoutFolder(),
"Iterated by Administrator");
WTDocument workingCopy = (WTDocument)link.getWorkingCopy();
//Check-In working copy of document to create new iteration
if(wt.vc.wip.WorkInProgressHelper.isCheckedOut(workingCopy)) {
ContentHolder holder = (FormatContentHolder) ContentHelper.service.getContents((ContentHolder)workingCopy);
ContentItem ci = ((FormatContentHolder) holder).getPrimary();
ContentServerHelper.service.deleteContent((ContentHolder)workingCopy, ci);
System.out.println("PersistenceHelper Modify");
workingCopy = (WTDocument) wt.vc.wip.WorkInProgressHelper.service.checkin(workingCopy,"MR. New iteration to set primary content to no content");
PersistenceHelper.manager.refresh(workingCopy);
}