Hi Windchillers,
Iam trying to download the latest copy of EPM document by using the following code; but the content downloaded is non latest. What could be the issue :
package com.phoenix.listen;
import wt.content.ApplicationData;
import wt.content.ContentHelper;
import wt.content.ContentItem;
import wt.content.ContentServerHelper;
import wt.content.FormatContentHolder;
import wt.epm.EPMDocument;
import wt.fc.PersistenceHelper;
import wt.fc.QueryResult;
import wt.query.QuerySpec;
import wt.query.SearchCondition;
import wt.util.WTException;
public class EPM_Doc_Pass {
public static boolean downloadFile(EPMDocument epmDoc, String downloadDirectory) {
boolean result=false;
ContentItem primaryContent=null;
String wtTemp = System.getProperty("wt.temp");
String fullName = wtTemp + "//" + downloadDirectory + "//" + epmDoc.getCADName();
String Docname = epmDoc.getName();
try {
// EPMDocument
if ( !epmDoc.isGeneric() ) {
QuerySpec qs = new QuerySpec (EPMDocument.class);
qs.appendWhere(new SearchCondition(EPMDocument.class,EPMDocument.NAME,SearchCondition.LIKE,Docname));
qs.appendAnd();
qs.appendSearchCondition (new SearchCondition (EPMDocument.class, "iterationInfo.latest", SearchCondition.IS_TRUE));
QueryResult qr = PersistenceHelper.manager.find(qs);
while (qr.hasMoreElements()) {
EPMDocument epmDoc1= (EPMDocument)qr.nextElement();
System.out.println(epmDoc1.getCADName()+ epmDoc1.getVersionDisplayIdentifier()+epmDoc1.getIterationDisplayIdentifier());
epmDoc1 = (EPMDocument) ContentHelper.service.getContents( epmDoc1 );
primaryContent = ContentHelper.getPrimary((FormatContentHolder)epmDoc1);
if ( primaryContent!=null )
{
System.out.println("downloadFile >>> EPMDocument, writeContentStream : " + fullName );
ContentServerHelper.service.writeContentStream( (ApplicationData)primaryContent, fullName );
result=true;
}
}
}
}
catch (Exception _e) {
_e.printStackTrace();
return false;
}
System.out.println("downloadFile >>> OUT...");
return(result);
}
}