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

Using newMultiObjectCopy to copy EPMDocuments

Highlighted
Participant

Using newMultiObjectCopy to copy EPMDocuments

Hi,

I'm trying to use the newMultiObjectCopy API from wt.enterprise.EnterpriseHelper and get

the error below.

javax.servlet.ServletException: wt.util.WTException: The value of "Owner Application" cannot be set to null, since it is a "required" attribute.
Verschachtelte Ausnahme ist: Der Wert von "Besitzer-Anwendung" kann nicht auf null eingestellt werden, da es ein "erforderliches" Attribut ist.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.netmarkets.jsp.nexiles.test_jsp._jspService(test_jsp.java:128)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
com.ptc.core.components.filter.JCARedirect.doFilter(JCARedirect.java:228)
wt.httpgw.filter.WTContextBeanFilter.doFilter(WTContextBeanFilter.java:48)
wt.httpgw.filter.TrustedAuthFilter.doFilter(TrustedAuthFilter.java:123)
wt.servlet.CompressionFilter.doFilter(CompressionFilter.java:232)
wt.servlet.RequestInterrupter.doFilter(RequestInterrupter.java:324)
wt.servlet.ServletRequestMonitor.doFilter(ServletRequestMonitor.java:1417)
wt.servlet.ServletRequestMonitorFilter.doFilter(ServletRequestMonitorFilter.java:54)

I've reduced the code to the following test case. This code runs w/o error on a Windchill 10.0 instance,

but I need to deploy on Windchill PDMLink 9.1.

<%@ page import="wt.fc.ReferenceFactory"%>

<%@ page import="wt.epm.EPMDocument"%>

<%@ page import="wt.epm.EPMContextHelper"%>

<%@ page import="wt.epm.EPMApplicationType"%>

<%@ page import="wt.enterprise.EnterpriseHelper"%>

<%@ page import="wt.enterprise.RevisionControlled"%>

<jsp:useBean id="wtcontext" class="wt.httpgw.WTContextBean" scope="request"/>

<jsp:setProperty name="wtcontext" property="request" value="<%=request%>"/>

<% response.setContentType("text/plain; charset=UTF-8"); out.println("#START"); ReferenceFactory RF = new ReferenceFactory(); String oid = "OR:wt.epm.EPMDocument:121033"; EPMDocument assembly = (EPMDocument)RF.getReference(oid).getObject(); out.println("name=" + assembly.getName()); out.println("ownerapp=" + assembly.getOwnerApplication()); RevisionControlled arr[] = new RevisionControlled[1]; arr[0] = assembly; EPMContextHelper.setApplication(EPMApplicationType.toEPMApplicationType("EPM")); out.println(EnterpriseHelper.service.newMultiObjectCopy(arr)); out.println("#-------------------------------------------------"); %>

Output (windchill 10, expected):

#START
name=rad.asm
ownerapp=EPM
[Lwt.enterprise.CopyObjectInfo;@903216a
#-------------------------------------------------

Any pointers would be very welcome.

Thanks,

Stefan.

1 REPLY 1

Re: Using newMultiObjectCopy to copy EPMDocuments

I understand it is pretty old stuff and not sure whether it is resolved or not... but still pasting working code snippet which I test yesterday.

 

I hope it help all community members!

 

                RevisionControlled copyRC = null;
		RevisionControlled afterSave = null;

		final Transaction trx = new Transaction();
		try{
			trx.start();
			final EPMDocument mdl = epm;

			EPMContextHelper.setApplication(EPMApplicationType.toEPMApplicationType("EPM"));
			copyRC = EnterpriseHelper.service.newCopy(mdl);

			final EPMDocument copy = (EPMDocument) copyRC;
			copy.setName(mdl.getName() + "_copy");
			copy.setNumber(mdl.getNumber() + "_copy");
			copy.setContainer(mdl.getContainer());
			copy.setOwnership(mdl.getOwnership());
			copy.setCADName("TestCopyFile.drw");
			afterSave = EnterpriseHelper.service.saveCopy(mdl,copy);
			trx.commit();
			System.out.println("Model has been saved, transaction completed: " + afterSave.getName());

		}
		catch(final Exception e){
			System.out.println(e.toString());
			trx.rollback();
		}
Announcements
LiveWorx Call For Papers Happening Now!