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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Fetch data for version A.1 only for EPM Document

prathi
12-Amethyst

Fetch data for version A.1 only for EPM Document

Hi,

We have written a utility to fetch the URL Drawing of a part created in Creo.

Code Snippet :

final QueryResult qr = PersistenceHelper.manager.find((StatementSpec)qs);

            while (qr.hasMoreElements()) {

                EPMDocument epmm = (EPMDocument) qr.nextElement();

                if ( (epmm.getNumber().endsWith(".drw")) || (epmm.getNumber().endsWith(".DRW")) && (internalUrl != null) && (internalUrl.length() > 0) )

                {

                    Representation defaultRep = RepresentationHelper.service

                            .getDefaultRepresentation(epmm);

                    ContentHolder holder;

                   

                        try {

                            holder = ContentHelper.service.getContents(defaultRep);

                           

                            Vector contents = ContentHelper

                                    .getContentListAll(holder);

                            ApplicationData data = null;

                           

                            WTProperties propName = WTProperties.getLocalProperties();

                           

                            String protocol= propName

                                    .getProperty("wt.webserver.protocol");

                           

                            String rmiHost = propName

                                    .getProperty("wt.rmi.server.hostname");

                       

                            String portUsed = propName.getProperty("wt.webserver.port");

                           

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

                                if (contents.get(i) instanceof ApplicationData) {

                                    data = (ApplicationData) contents.get(i);

                                                               

                                    URL aURL = WVSContentHelper.getDownloadURL(

                                            data, holder);

                               

                                 String cURL = null;

                                 String result = null;

                                

                                    if ( aURL.toString().contains("pvs") ){

                                

                                    cURL= aURL.toString();

                                   

                                    result = cURL.substring(cURL.indexOf("ContentHolder=")+14, cURL.indexOf("&u8=1"));

                                 

                                    String rmiHostName = "&objref=OR%3A";

                              

                                    internalUrl = internalUrl

                                            .substring(

                                                    internalUrl.indexOf("createCDialogWindow('") +21,

                                                    internalUrl

                                                            .indexOf("http:"));

                                   

                           

                                                               

                                    finalURL = protocol + "://" + rmiHost + ":" + portUsed +internalUrl + cURL +  rmiHostName + result;

                                            ;

                              

                                    break;

It was working fine, but recently we found a limitation. If we revise the Drawing from Windchill and then re run the utility, It shows a Java Array size error.

wt.method.MethodContextMonitor.contexts.rmi wcadmin - 2016-06-13 14:19:41.555 +0530, 2vtvcx;ipds3u2q;6884;36sq4k;1, -, -, -, wcadmin, 10.101.11.1, ext.havells.utilities.Eight, prepareDataForExcel, , 0, 571, 0.255354489, 2, 0.002308162, 0.5148033, 0.787921406

java.lang.StringIndexOutOfBoundsException: String index out of range: -21

    at java.lang.String.substring(String.java:1911)

    at ext.havells.utilities.Eight.getDrawingLink(Eight.java:504)

    at ext.havells.utilities.Eight.writeIntoExcel(Eight.java:283)

    at ext.havells.utilities.Eight.prepareDataForExcel(Eight.java:174)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

    at java.lang.reflect.Method.invoke(Method.java:606)

and so on.

On my investigation, i think that it is because of these multi revisions of drawing, it is failing.I tried using some APIs could not solve this .

Request you to help me solve this.                                                                                                                                                                                                                                                                                                 

2 REPLIES 2
satre-2
12-Amethyst
(To:prathi)

From stacktrace it seems like error is on below line.  Your code does not explain what internalURL is, but it seems like your length of internalURL is less than internalUrl.indexOf("createCDialogWindow('") +21.

internalUrl = internalUrl.substring(internalUrl.indexOf("createCDialogWindow('") +21,internalUrl.indexOf("http:"));

I am not sure if you are getting download URL using WVSContentHelper.getDownloadURL API   then why you are constructing new URL finalURL.

Hope it helps!!

Thanks

Shreyas

prathi
12-Amethyst
(To:satre-2)

Hi,

Below are details regarding internalURL.

String javascriptKey = "javascript";

VSResult result2 = UIHelper.getLaunchProductView(partRef,

                    new Boolean(true), SessionHelper.getLocale());

String internalUrl = (String) ((HashMap<String, Object>) result2

                    .getObject()).get(javascriptKey);

From WVSContentHelper.getDownloadURL, we are getting multiple URLs. To get the one related to drawing link we are sorting using ".pvs". But the URL obtained here is not sufficient to open the drawing link. So we are adding few terms before and after the URL obtained and thus making a final URL.

The length is not less that the required length. Refer below for reference :

2016-06-13 14:19:42,330 INFO  [RMI TCP Connection(516)-10.101.11.1] wt.system.out wcadmin - NameDEMOPART23 DRW

2016-06-13 14:19:42,331 INFO  [RMI TCP Connection(516)-10.101.11.1] wt.system.out wcadmin - NumberIDEMOPART23.DRW

2016-06-13 14:19:42,333 INFO  [RMI TCP Connection(516)-10.101.11.1] wt.system.out wcadmin - aURLhttp://cri-test.hodomain.com/Windchill/servlet/WindchillAuthGW/com.ptc.wvs.server.util.WVSContentHelper/redirectDownload/DEMOPART23.pvs?HttpOperationItem=wt.content.ApplicationData%3A47511377&ContentHolder=wt.viewmarkup.DerivedImage%3A47511357&u8=1

2016-06-13 14:19:42,333 INFO  [RMI TCP Connection(516)-10.101.11.1] wt.system.out wcadmin - result :wt.viewmarkup.DerivedImage%3A47511357

2016-06-13 14:19:42,333 INFO  [RMI TCP Connection(516)-10.101.11.1] wt.system.out wcadmin - rmiHostName :&objref=OR%3A

2016-06-13 14:19:42,333 INFO  [RMI TCP Connection(516)-10.101.11.1] wt.system.out wcadmin - internalUrl :/Windchill/wtcore/jsp/wvs/edrview.jsp?url=

2016-06-13 14:19:42,334 DEBUG [RMI TCP Connection(516)-10.101.11.1] ext.havells.utilities.Eight wcadmin - ###### finalURL : http://cri-test.hodomain.com:80/Windchill/wtcore/jsp/wvs/edrview.jsp?url=http://cri-test.hodomain.com/Windchill/servlet/WindchillAuthGW/com.ptc.wvs.server.util.WVSContentHelper/redirectDownload/DEMOPART23.pvs?HttpOperationItem=wt.content.ApplicationData%3A47511377&ContentHolder=wt.viewmarkup.Derived...

2016-06-13 14:19:42,334 DEBUG [RMI TCP Connection(516)-10.101.11.1] ext.havells.utilities.Eight wcadmin - drawingLink=http://cri-test.hodomain.com:80/Windchill/wtcore/jsp/wvs/edrview.jsp?url=http://cri-test.hodomain.com/Windchill/servlet/WindchillAuthGW/com.ptc.wvs.server.util.WVSContentHelper/redirectDownload/DEMOPART23.pvs?HttpOperationItem=wt.content.ApplicationData%3A47511377&ContentHolder=wt.viewmarkup.Derived...

2016-06-13 14:19:42,334 DEBUG [RMI TCP Connection(516)-10.101.11.1] ext.havells.utilities.Eight wcadmin - Inside getDrawingLink method

2016-06-13 14:19:42,335 INFO  [RMI TCP Connection(516)-10.101.11.1] wt.system.out wcadmin - internalUrlactual :createCDialogWindow('/Windchill/wtcore/jsp/wvs/edrview.jsp?url=http://cri-test.hodomain.com/Windchill/servlet/WindchillAuthGW/com.ptc.wvs.server.ui.UIHelper/getPartStructureED&partid=OR%3Awt.part.WTPart%3A47506756&levels=-1&partstructure=1', 'ProductViewLite', '800', '650','0','0');

2016-06-13 14:19:42,336 INFO  [RMI TCP Connection(516)-10.101.11.1] wt.system.out wcadmin - NameDEMOPART21 DRW

2016-06-13 14:19:42,336 INFO  [RMI TCP Connection(516)-10.101.11.1] wt.system.out wcadmin - NumberIDEMOPART21.DRW

2016-06-13 14:19:42,339 INFO  [RMI TCP Connection(516)-10.101.11.1] wt.system.out wcadmin - aURLhttp://cri-test.hodomain.com/Windchill/servlet/WindchillAuthGW/com.ptc.wvs.server.util.WVSContentHelper/redirectDownload/DEMOPART21.pvs?HttpOperationItem=wt.content.ApplicationData%3A47504248&ContentHolder=wt.viewmarkup.DerivedImage%3A47504225&u8=1

2016-06-13 14:19:42,339 INFO  [RMI TCP Connection(516)-10.101.11.1] wt.system.out wcadmin - result :wt.viewmarkup.DerivedImage%3A47504225

2016-06-13 14:19:42,339 INFO  [RMI TCP Connection(516)-10.101.11.1] wt.system.out wcadmin - rmiHostName :&objref=OR%3A

2016-06-13 14:19:42,339 INFO  [RMI TCP Connection(516)-10.101.11.1] wt.system.out wcadmin - internalUrl :/Windchill/wtcore/jsp/wvs/edrview.jsp?url=

2016-06-13 14:19:42,339 DEBUG [RMI TCP Connection(516)-10.101.11.1] ext.havells.utilities.Eight wcadmin - ###### finalURL : http://cri-test.hodomain.com:80/Windchill/wtcore/jsp/wvs/edrview.jsp?url=http://cri-test.hodomain.com/Windchill/servlet/WindchillAuthGW/com.ptc.wvs.server.util.WVSContentHelper/redirectDownload/DEMOPART21.pvs?HttpOperationItem=wt.content.ApplicationData%3A47504248&ContentHolder=wt.viewmarkup.Derived...

2016-06-13 14:19:42,339 INFO  [RMI TCP Connection(516)-10.101.11.1] wt.system.out wcadmin - NameDEMOPART21 DRW

2016-06-13 14:19:42,339 INFO  [RMI TCP Connection(516)-10.101.11.1] wt.system.out wcadmin - NumberIDEMOPART21.DRW

2016-06-13 14:19:42,342 INFO  [RMI TCP Connection(516)-10.101.11.1] wt.system.out wcadmin - aURLhttp://cri-test.hodomain.com/Windchill/servlet/WindchillAuthGW/com.ptc.wvs.server.util.WVSContentHelper/redirectDownload/DEMOPART21.pvs?HttpOperationItem=wt.content.ApplicationData%3A47574253&ContentHolder=wt.viewmarkup.DerivedImage%3A47574250&u8=1

2016-06-13 14:19:42,342 INFO  [RMI TCP Connection(516)-10.101.11.1] wt.system.out wcadmin - result :wt.viewmarkup.DerivedImage%3A47574250

2016-06-13 14:19:42,342 INFO  [RMI TCP Connection(516)-10.101.11.1] wt.system.out wcadmin - rmiHostName :&objref=OR%3A

2016-06-13 14:19:42,343 ERROR [RMI TCP Connection(516)-10.101.11.1] wt.method.MethodContextMonitor.contexts.rmi wcadmin - 2016-06-13 14:19:41.555 +0530, 2vtvcx;ipds3u2q;6884;36sq4k;1, -, -, -, wcadmin, 10.101.11.1, ext.havells.utilities.Eight, prepareDataForExcel, , 0, 571, 0.255354489, 2, 0.002308162, 0.5148033, 0.787921406

java.lang.StringIndexOutOfBoundsException: String index out of range: -21

    at java.lang.String.substring(String.java:1911)

Here DEMOPART 23 does not has the Drawing link revised and hence is called once, but for DEMOPART 21 the Drawing link is revised and hence it is being called twice.  If you see the Internal Actual url for DEMOPART 21 is printed only once. so it seems to be same for both revisions.

Announcements


Top Tags