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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Persistent Request Issue When Updating EPMDocument ID in Java Application

ozclkonur
13-Aquamarine

Persistent Request Issue When Updating EPMDocument ID in Java Application

 

I have a code like this, and I ran it in its current state, and it worked. After that, I changed the ID value in this part ("wt.epm.EPMDocument:114592789") and assigned another EPMDocument ID. Of course, I also changed the file name and file path. When I ran it again, it still tried to send the request using the first information I used. In the console, it gave a warning saying something like "this has already been added" or similar. I tried a few more IDs, but each time it attempted to process using the first information I sent. Is this problem due to Eclipse, or is there an issue in the code? Can you help me?
 
-------------------------------------------------------------------------------------------------------
 
package ext.designtech.utils;

 

import java.beans.PropertyVetoException;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;

 

import wt.content.ApplicationData;
import wt.content.ContentHolder;
import wt.content.ContentRoleType;
import wt.content.ContentServerHelper;
import wt.epm.EPMDocument;
import wt.fc.Persistable;
import wt.fc.PersistenceHelper;
import wt.fc.WTObject;
import wt.method.RemoteAccess;
import wt.method.RemoteMethodServer;
import wt.pom.Transaction;
import wt.util.WTException;
import wt.util.WTPropertyVetoException;

 

public class UploadUtil implements RemoteAccess {

 

    public static void main(String[] args)
            throws WTExceptionPropertyVetoExceptionIOExceptionInvocationTargetException {

 

        RemoteMethodServer myServer = RemoteMethodServer.getDefault();
        myServer.setUserName("plm-1");
        myServer.setPassword("Des.23!Tech");

 

        // Generic kullan?m? düzelttik
        Class[] paramTypes = {};
        Object[] paramValues = {};
        myServer.invoke("upload"UploadUtil.class.getName(), nullparamTypesparamValues);
    }

 

    public static void upload() throws WTExceptionPropertyVetoExceptionIOException {

 

        Transaction tx = new Transaction();
        try {

 

            wt.fc.ObjectIdentifier oid = wt.fc.ObjectIdentifier.newObjectIdentifier("wt.epm.EPMDocument:114592789");

 

            // Cast i?lemi düzgün ?ekilde yap?ld?
            EPMDocument doc = (EPMDocumentPersistenceHelper.manager.refresh(oid);
            System.out.println(doc);

 

            ContentHolder ch = (ContentHolderdoc;
            ApplicationData theContent = ApplicationData.newApplicationData(ch);
            String filename = "vns-042754_2ad.pdf";
            File theFile = new File("C:\\Users\\PLM-1\\Desktop\\vns-042754_2ad.pdf");



            if(theContent == null){
               
            theContent.setFileName(filename);
            String path = "C:\\Users\\PLM-1\\Desktop\\vns-042754_2ad.pdf";
            theContent.setUploadedFromPath(path);
            theContent.setRole(ContentRoleType.SECONDARY); // Enum tipi olarak düzeltildi
            System.out.println("---Role Set---");
            theContent.setFileSize(theFile.length());
            }else{
                theContent.setFileName(filename);
                theContent.setUploadedFromPath("C:\\Users\\PLM-1\\Desktop\\vns-042754_2ad.pdf");
                theContent.setFileSize(theFile.length());
            }
           
           
            FileInputStream fis = new FileInputStream(theFile);
           

 

            System.out.println("--Upload Begin--");

 

            tx.start();
            theContent = ContentServerHelper.service.updateContent(chtheContentfis);
            tx.commit();

 

            ContentServerHelper.service.updateHolderFormat(doc);
            doc = (EPMDocumentPersistenceHelper.manager.refresh((Persistabledoctruetrue);
            System.out.println("---Attachment attached---");

 

            fis.close();
        } catch (WTPropertyVetoException e) {
            e.printStackTrace();
            tx.rollback(); // Transaction ba?ar?s?z oldu?unda geri al
        } catch (Exception e) {
            e.printStackTrace();
            tx.rollback(); // Genel hatalar için geri al
        }
    }

 

}
2 REPLIES 2

Hi,

Check in Windchill if there is a document with the same file name. Windchill does not like the same file name even if they are different by content , and even if it was attached to different objects. Try this manually and see for yourself. Your file names are the same for the 1st upload and 2nd, going by the log.

Cheers

Hari

 

ozclkonur
13-Aquamarine
(To:Hari_Vara)

I've successfully implemented file deletion, but when I check MethodServer, it keeps logging the same message, repeatedly attempting to send the part with the EPMDocument ID 114592789. This was the ID I tried to process when I first ran the application. Since then, I've attempted to attach parts to different EPMDocument IDs like 129025898, but MethodServer keeps making requests for the initial ID. It continuously shows the same log. Is there a way to clear the MethodServer or bypass this issue?

Announcements


Top Tags