cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

API to create EPMdocument with two iterations. A.1 and A.2

vuchekar
10-Marble

API to create EPMdocument with two iterations. A.1 and A.2

Hi All,

I am able to create a EPMDocument with API at first time.

i want to iterate this EPMdocument for updating its contents, how i can do this, because my code gives me "Error in Document Createwt.vc.VersionControlException: wt.util.WTException: wt.pom.UniquenessException: CAD Part" exception.

Please help me to Build the EPMdocument A.1 and A.2 with modified contents.

any help will be great.

Regards,

Vivek

3 REPLIES 3

Hi.

You can create EPMDocument A1 and add the content. Then check out it, modify content and check in it.

Hi Anton,

Thanks for your response.

Now i am able to check out the EPMDocument with API, and check in back to Windchill without modifying the content.

as simple part A.1 to Part A.2.

but when i am trying to update its content, it gives me below error, please suggest how i can modify the content file also while check in i to Windchill.

Uploading file to Primary

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)

Finished uploadFile of [wt.epm.EPMDocument:194491]Caused by: (wt.content.contentResource/66) wt.content.ContentException: Can not add more than one primary content to the object.

===============================

i am using below code for check out EPMDoc.

//check out

        wt.vc.wip.WorkInProgressHelper.service.checkout(doc, wt.vc.wip.WorkInProgressHelper.service.getCheckoutFolder(),"Iterated by Administrator");

        System.out.println("Checked Out ...done.");

//for Check In

if(wt.vc.wip.WorkInProgressHelper.isCheckedOut(epm)) {

  epm = (wt.epm.EPMDocument) wt.vc.wip.WorkInProgressHelper.service.checkin(epm,"checked in by xxx");

  }

=======================

Please let me know how i can modify the content of EPMDoc and check in back to Windchill.

Any sample code will be great help.

Regards,

Vivek

Hi Vivek. I have never updated primary contents by code, but I am using below code for seting the secondary content:

public static void addDescribeFileToDoc(WTDocument wtd, File file) throws Exception

  {

  System.out.println("Add secondary");

  byte[] byteArray = FileUtils.readFileToByteArray(file);

ContentHolderHelper.setContents(wtd, byteArray, ContentRoleType.SECONDARY, file.getName(), "", false);

  }

You may try to change this method like this:

public static void updatePrimaryFileToDoc(WTDocument wtd, File file) throws Exception

  {

  System.out.println("Add secondary");

  byte[] byteArray = FileUtils.readFileToByteArray(file);

ContentHolderHelper.updateContents(wtd, byteArray, ContentRoleType.PRIMARY);

  }

Announcements


Top Tags