Skip to main content
1-Visitor
July 25, 2013
Question

How to download & Save WTDocument primary content using Windchill API ?

  • July 25, 2013
  • 1 reply
  • 4202 views

I have a requirement like I need to download either primary or secondary content to WC Server Local HardDisk.

I am able to achive this using desktop.getdesktop().browse(new uri(Windchill_DocDownload_URL)) . If any better method is there please suggest.

1 reply

1-Visitor
July 26, 2013

Hi Manikandan,

Please try the following code in any utility class,

ContentHolder content = ContentHelper.service.getContents((ContentHolder)documentObject);

Vector<?> vcontent = ContentHelper.getApplicationData(content); // this will return all contents

if(vcontent.size() > 0){

for(int i=0; i<vcontent.size(); i++) {

wt.content.ApplicationData appData = (ApplicationData)vcontent.get(i);

String currfileName = appData.getFileName();

File saveAsFile= new java.io.File("D:/",currfileName); // input your location and file name

ContentServerHelper.service.writeContentStream((ApplicationData)appData, saveAsFile.getCanonicalPath());

}

}

you can also download the content for role too, have look on following method and modify to suit your requirement,

QueryResult getContentsByRole(ContentHolder holder, ContentRoleType role) throws WTException

public static final ContentRoleType PRIMARY

public static final ContentRoleType SECONDARY

Njoy,

MKR

1-Visitor
July 26, 2013

Thanks a lot brother.

getContentsByRole(ContentHolder holder, ContentRoleType role) is perfect solution for my requirement.

and also I tried your above code ,In that if(vcontent.size() > 0) always not entering.

By

Mani